]> git.ipfire.org Git - thirdparty/git.git/commitdiff
repack: delete geometric packs via existing_packs
authorTaylor Blau <me@ttaylorr.com>
Fri, 26 Jun 2026 19:02:27 +0000 (15:02 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 Jun 2026 21:54:55 +0000 (14:54 -0700)
Now that packs above the geometric split are marked as retained, teach
geometric repacks to use the existing_packs deletion machinery instead of
calling pack_geometry_remove_redundant().

This lets geometric repacks share the same mark-then-remove path as
all-into-one repacks: packs below the split are marked for deletion, and
packs above the split are ignored because they were retained earlier.

When doing a geometric repack without --combine-cruft-below-size, retain
all cruft packs before marking anything for deletion. Geometric repacks do
not rewrite cruft packs in that mode, so the common deletion path must not
remove them.

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

index 66b46b86896d7e91f807779a9e178f0a7d35abf0..dfb6fed231d3c1a88b8f1da995a7f659cb18658b 100644 (file)
@@ -574,10 +574,13 @@ int cmd_repack(int argc,
                                       packtmp);
        /* End of pack replacement. */
 
-       if (delete_redundant && pack_everything & ALL_INTO_ONE) {
+       if (delete_redundant) {
                if (write_midx == REPACK_WRITE_MIDX_INCREMENTAL)
                        existing_packs_retain_midx_packs(&existing, &geometry);
-               existing_packs_mark_for_deletion(&existing, &names);
+               if (geometry.split_factor && !combine_cruft_below_size)
+                       existing_packs_retain_all_cruft(&existing);
+               if (pack_everything & ALL_INTO_ONE || geometry.split_factor)
+                       existing_packs_mark_for_deletion(&existing, &names);
        }
 
        if (write_midx != REPACK_WRITE_MIDX_NONE) {
@@ -609,10 +612,6 @@ int cmd_repack(int argc,
                existing_packs_remove_redundant(&existing, packdir,
                                                wrote_incremental_midx);
 
-               if (geometry.split_factor)
-                       pack_geometry_remove_redundant(&geometry, &names,
-                                                      &existing, packdir,
-                                                      wrote_incremental_midx);
                if (show_progress)
                        opts |= PRUNE_PACKED_VERBOSE;
                prune_packed_objects(opts);
index c7b79a3c1137a2159475e520821df00ed23903ae..90797561954ae651257b55ecc573452d257db4f7 100644 (file)
--- a/repack.c
+++ b/repack.c
@@ -242,6 +242,14 @@ static struct string_list_item *locate_existing_pack(struct string_list *list,
        return item;
 }
 
+void existing_packs_retain_all_cruft(struct existing_packs *existing)
+{
+       struct string_list_item *item;
+
+       for_each_string_list_item(item, &existing->cruft_packs)
+               existing_packs_mark_retained(item);
+}
+
 void existing_packs_retain_cruft(struct existing_packs *existing,
                                 struct packed_git *cruft)
 {
index f0d082df9e8accfce8905116d26690cd470cfd7f..90c89630ef808a43a8bca7bf9d7e9925bd48f493 100644 (file)
--- a/repack.h
+++ b/repack.h
@@ -81,6 +81,7 @@ void existing_packs_collect(struct existing_packs *existing,
                            const struct string_list *extra_keep);
 int existing_packs_has_non_kept(const struct existing_packs *existing);
 int existing_pack_is_marked_for_deletion(struct string_list_item *item);
+void existing_packs_retain_all_cruft(struct existing_packs *existing);
 void existing_packs_retain_cruft(struct existing_packs *existing,
                                 struct packed_git *cruft);
 void existing_packs_retain_from_geometry(struct existing_packs *existing,