]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/repack.c
builtin/repack.c: invalidate MIDX only when necessary
authorTaylor Blau <me@ttaylorr.com>
Tue, 25 Aug 2020 16:04:36 +0000 (12:04 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 26 Aug 2020 20:55:46 +0000 (13:55 -0700)
commite08f7bb09369d739ef03e1ac0180140a68e70982
tree24094a6d231882be43920025413e4d15f3d11301
parent47ae905ffb98cc4d4fd90083da6bc8dab55d9ecc
builtin/repack.c: invalidate MIDX only when necessary

In 525e18c04b (midx: clear midx on repack, 2018-07-12), 'git repack'
learned to remove a multi-pack-index file if it added or removed a pack
from the object store.

This mechanism is a little over-eager, since it is only necessary to
drop a MIDX if 'git repack' removes a pack that the MIDX references.
Adding a pack outside of the MIDX does not require invalidating the
MIDX, and likewise for removing a pack the MIDX does not know about.

Teach 'git repack' to check for this by loading the MIDX, and checking
whether the to-be-removed pack is known to the MIDX. This requires a
slightly odd alternation to a test in t5319, which is explained with a
comment. A new test is added to show that the MIDX is left alone when
both packs known to it are marked as .keep, but two packs unknown to it
are removed and combined into one new pack.

Helped-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/repack.c
t/t5319-multi-pack-index.sh