mirror of
https://github.com/git/git
synced 2024-09-13 21:34:42 +00:00
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>
This commit is contained in:
parent
6dda4e60f2
commit
d6cd00c768
|
@ -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".
|
* normalize these forms to "foo.pack" for "index-pack --verify".
|
||||||
*/
|
*/
|
||||||
strbuf_addstr(&arg, path);
|
strbuf_addstr(&arg, path);
|
||||||
if (ends_with(arg.buf, ".idx"))
|
if (strbuf_strip_suffix(&arg, ".idx") ||
|
||||||
strbuf_splice(&arg, arg.len - 3, 3, "pack", 4);
|
!ends_with(arg.buf, ".pack"))
|
||||||
else if (!ends_with(arg.buf, ".pack"))
|
strbuf_addstr(&arg, ".pack");
|
||||||
strbuf_add(&arg, ".pack", 5);
|
|
||||||
argv[2] = arg.buf;
|
argv[2] = arg.buf;
|
||||||
|
|
||||||
memset(&index_pack, 0, sizeof(index_pack));
|
memset(&index_pack, 0, sizeof(index_pack));
|
||||||
|
|
Loading…
Reference in a new issue