]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/repack.c: avoid making cruft packs preferred
authorTaylor Blau <me@ttaylorr.com>
Tue, 3 Oct 2023 21:54:19 +0000 (17:54 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Oct 2023 20:26:11 +0000 (13:26 -0700)
commit3c1e2c2113842b8462803ef8c9aca596eacfd3af
treee06d12e0d42ef93e7ecbd59219be19f87c81cc6f
parent37dc6d81042ac41437163264e7a29d3bf50c8d90
builtin/repack.c: avoid making cruft packs preferred

When doing a `--geometric` repack, we make sure that the preferred pack
(if writing a MIDX) is the largest pack that we *didn't* repack. That
has the effect of keeping the preferred pack in sync with the pack
containing a majority of the repository's reachable objects.

But if the repository happens to double in size, we'll repack
everything. Here we don't specify any `--preferred-pack`, and instead
let the MIDX code choose.

In the past, that worked fine, since there would only be one pack to
choose from: the one we just wrote. But it's no longer necessarily the
case that there is one pack to choose from. It's possible that the
repository also has a cruft pack, too.

If the cruft pack happens to come earlier in lexical order (and has an
earlier mtime than any non-cruft pack), we'll pick that pack as
preferred. This makes it impossible to reuse chunks of the reachable
pack verbatim from pack-objects, so is sub-optimal.

Luckily, this is a somewhat rare circumstance to be in, since we would
have to repack the entire repository during a `--geometric` repack, and
the cruft pack would have to sort ahead of the pack we just created.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/repack.c
t/t7704-repack-cruft.sh