]> git.ipfire.org Git - thirdparty/git.git/commit
midx-write: skip rewriting MIDX with `--stdin-packs` unless needed
authorPatrick Steinhardt <ps@pks.im>
Wed, 10 Dec 2025 12:52:20 +0000 (13:52 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 11 Dec 2025 03:09:59 +0000 (12:09 +0900)
commit6ce9d558ced275a707393d044e5b0035412f8360
tree5128c927a5fb042b5b36b91ae7beaf3e056e2c2c
parentb3bab9d2729fde1f52c407447711c34a75c5c377
midx-write: skip rewriting MIDX with `--stdin-packs` unless needed

In `write_midx_internal()` we know to skip rewriting the multi-pack
index in case the existing one already covers all packs. This logic does
not know to handle `git multi-pack-index write --stdin-packs` though, so
we end up always rewriting the MIDX in this case even if the MIDX would
not change.

With our default maintenance strategy this isn't really much of a
problem, as git-gc(1) does not use the "--stdin-packs" option. But that
is changing with geometric repacking, where "--stdin-packs" is used to
explicitly select the packfiles part of the geometric sequence.

This issue can be demonstrated trivially with a benchmark in the Git
repository: executing `git repack --geometric=2 --write-midx -d` in the
Git repository takes more than 3 seconds only to end up with the same
multi-pack index as we already had before.

The logic that decides if we need to rewrite the MIDX only checks
whether the number of packfiles covered will change. That check is of
course too lenient for "--stdin-packs", as it could happen that we want
to cover a different-but-same-size set of packfiles. But there is no
inherent reason why we cannot handle "--stdin-packs".

Improve the logic to not only check for the number of packs, but to also
verify that we are asked to generate a MIDX for the _same_ packs. This
allows us to also skip no-op rewrites for "--stdin-packs".

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