Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-06-30 21:02:05 +0400
committerJunio C Hamano <gitster@pobox.com>2014-07-01 00:43:32 +0400
commitd6cd00c76866a6412e0c13da91a022acdd187a47 (patch)
treeb2b37077b5e3646bd880d3e49a0169c0de4232b9 /builtin/verify-pack.c
parent6dda4e60f2c3c309de6e3fe1b86a47846a86dabf (diff)
verify-pack: use strbuf_strip_suffix
In this code, we try to convert both "foo.idx" and "foo" into "foo.pack". By stripping the suffix, we can avoid a confusing use of strbuf_splice, and make it clear that both cases are adding ".pack" to the end. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/verify-pack.c')
-rw-r--r--builtin/verify-pack.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/builtin/verify-pack.c b/builtin/verify-pack.c
index 2fd29cee8d..972579f33c 100644
--- a/builtin/verify-pack.c
+++ b/builtin/verify-pack.c
@@ -27,10 +27,9 @@ static int verify_one_pack(const char *path, unsigned int flags)
* normalize these forms to "foo.pack" for "index-pack --verify".
*/
strbuf_addstr(&arg, path);
- if (ends_with(arg.buf, ".idx"))
- strbuf_splice(&arg, arg.len - 3, 3, "pack", 4);
- else if (!ends_with(arg.buf, ".pack"))
- strbuf_add(&arg, ".pack", 5);
+ if (strbuf_strip_suffix(&arg, ".idx") ||
+ !ends_with(arg.buf, ".pack"))
+ strbuf_addstr(&arg, ".pack");
argv[2] = arg.buf;
memset(&index_pack, 0, sizeof(index_pack));