]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/repack.c: extract marking packs for deletion
authorTaylor Blau <me@ttaylorr.com>
Wed, 13 Sep 2023 19:17:46 +0000 (15:17 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 13 Sep 2023 19:32:47 +0000 (12:32 -0700)
commit054b5e4873d9ef2348f0880d66f1acf73bad7d59
treeb692ff96024f7dea594d38a256c6e0a3568fc376
parente2b43831a5e4b482be19746d2257a309b51ba5fe
builtin/repack.c: extract marking packs for deletion

At the end of a repack (when given `-d`), Git attempts to remove any
packs which have been made "redundant" as a result of the repacking
operation. For example, an all-into-one (`-A` or `-a`) repack makes
every pre-existing pack which is not marked as kept redundant. Geometric
repacks (with `--geometric=<n>`) make any packs which were rolled up
redundant, and so on.

But before deleting the set of packs we think are redundant, we first
check to see whether or not we just wrote a pack which is identical to
any one of the packs we were going to delete. When this is the case, Git
must avoid deleting that pack, since it matches a pack we just wrote
(so deleting it may cause the repository to become corrupt).

Right now we only process the list of non-kept packs in a single pass.
But a future change will split the existing non-kept packs further into
two lists: one for cruft packs, and another for non-cruft packs.

Factor out this routine to prepare for calling it twice on two separate
lists in a future patch.

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