]> git.ipfire.org Git - thirdparty/git.git/commit
repack: respect --keep-pack with geometric repack
authorVictoria Dye <vdye@github.com>
Fri, 20 May 2022 19:01:45 +0000 (15:01 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 May 2022 19:56:29 +0000 (12:56 -0700)
commit4b5a808bb906896e07ca147645b33feb81e91c4c
tree473cfdafb467e32a42ba0c724456b72289e0c4ed
parente54793a95afeea1e10de1e5ad7eab914e7416250
repack: respect --keep-pack with geometric repack

Update 'repack' to ignore packs named on the command line with the
'--keep-pack' option. Specifically, modify 'init_pack_geometry()' to treat
command line-kept packs the same way it treats packs with an on-disk '.keep'
file (that is, skip the pack and do not include it in the 'geometry'
structure).

Without this handling, a '--keep-pack' pack would be included in the
'geometry' structure. If the pack is *before* the geometry split line (with
at least one other pack and/or loose objects present), 'repack' assumes the
pack's contents are "rolled up" into another pack via 'pack-objects'.
However, because the internally-invoked 'pack-objects' properly excludes
'--keep-pack' objects, any new pack it creates will not contain the kept
objects. Finally, 'repack' deletes the '--keep-pack' as "redundant" (since
it assumes 'pack-objects' created a new pack with its contents), resulting
in possible object loss and repository corruption.

Add a test ensuring that '--keep-pack' packs are now appropriately handled.

Co-authored-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/repack.c
t/t7703-repack-geometric.sh