]> git.ipfire.org Git - thirdparty/git.git/commit
repack: fix trying to use preferred pack in alternates
authorPatrick Steinhardt <ps@pks.im>
Fri, 14 Apr 2023 06:01:36 +0000 (08:01 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Apr 2023 17:27:51 +0000 (10:27 -0700)
commit3d74a2337c679839265efa16b2bca2a9b7795a00
tree8dd6c351133f15213cdad19fa4ab1a098d4f45b0
parentceb96a160b05c3ec45c416851bac00b711418839
repack: fix trying to use preferred pack in alternates

When doing a geometric repack with multi-pack-indices, then we ask
git-multi-pack-index(1) to use the largest packfile as the preferred
pack. It can happen though that the largest packfile is not part of the
main object database, but instead part of an alternate object database.
The result is that git-multi-pack-index(1) will not be able to find the
preferred pack and print a warning. It then falls back to use the first
packfile that the multi-pack-index shall reference.

Fix this bug by only considering packfiles as preferred pack that are
local. This is the right thing to do given that a multi-pack-index
should never reference packfiles borrowed from an alternate.

While at it, rename the function `get_largest_active_packfile()` to
`get_preferred_pack()` to better document its intent.

Helped-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/repack.c
t/t7703-repack-geometric.sh