]> git.ipfire.org Git - thirdparty/git.git/commit - t/t5319-multi-pack-index.sh
packfile: fix pack basename computation
authorJeff King <peff@peff.net>
Fri, 5 Apr 2019 18:06:22 +0000 (14:06 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Apr 2019 07:58:21 +0000 (16:58 +0900)
commitfc78915674ff1bca1726348d7c434dfa0048a5d7
treea9ad9e7e74fcdbd4121b36a2569fa27407283a7f
parent013fd7ada3c81cec8f0c48427c77394028707c2e
packfile: fix pack basename computation

When we have a multi-pack-index that covers many packfiles, we try to
avoid opening the .idx for those packfiles. To do that we feed the pack
name to midx_contains_pack(). But that function wants to see only the
basename, which we compute using strrchr() to find the final slash. But
that leaves an extra "/" at the start of our string.

We can fix this by incrementing the pointer. That also raises the
question of what to do when the name does not have a '/' at all. This
should generally not happen (we always find files in "pack/"), but it
doesn't hurt to be defensive here.

Let's wrap all of that up in a helper function and make it publicly
available, since a later patch will need to use it, too.

The tests don't notice because there's nothing about opening those .idx
files that would cause us to give incorrect output. It's just a little
slower. The new test checks this case by corrupting the covered .idx,
and then making sure we don't complain about it.

We also have to tweak t5570, which intentionally corrupts a .idx file
and expects us to notice it. When run with GIT_TEST_MULTI_PACK_INDEX,
this will fail since we now will (correctly) not bother opening the .idx
at all. We can fix that by unconditionally dropping any midx that's
there, which ensures we'll have to read the .idx.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
packfile.c
packfile.h
t/t5319-multi-pack-index.sh
t/t5570-git-daemon.sh