repack: delete geometric packs via existing_packs

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>

Taylor Blau committed Jun 26, 2026 at 15:02 UTC 4adadb015781bdfec02120f9b1fa5a606d8c7cfd
3 files changed +14 -6
builtin/repack.c
+5 -6
@@ -574,10 +574,13 @@ int cmd_repack(int argc,
574 packtmp);
575 /* End of pack replacement. */
576
577 - if (delete_redundant && pack_everything & ALL_INTO_ONE) {
577 + if (delete_redundant) {
578 if (write_midx == REPACK_WRITE_MIDX_INCREMENTAL)
579 existing_packs_retain_midx_packs(&existing, &geometry);
580 - existing_packs_mark_for_deletion(&existing, &names);
580 + if (geometry.split_factor && !combine_cruft_below_size)
581 + existing_packs_retain_all_cruft(&existing);
582 + if (pack_everything & ALL_INTO_ONE || geometry.split_factor)
583 + existing_packs_mark_for_deletion(&existing, &names);
584 }
585
586 if (write_midx != REPACK_WRITE_MIDX_NONE) {
@@ -609,10 +612,6 @@ int cmd_repack(int argc,
612 existing_packs_remove_redundant(&existing, packdir,
613 wrote_incremental_midx);
614
612 - if (geometry.split_factor)
613 - pack_geometry_remove_redundant(&geometry, &names,
614 - &existing, packdir,
615 - wrote_incremental_midx);
615 if (show_progress)
616 opts |= PRUNE_PACKED_VERBOSE;
617 prune_packed_objects(opts);
repack.c
+8
@@ -242,6 +242,14 @@ static struct string_list_item *locate_existing_pack(struct string_list *list,
242 return item;
243 }
244
245 +void existing_packs_retain_all_cruft(struct existing_packs *existing)
246 +{
247 + struct string_list_item *item;
248 +
249 + for_each_string_list_item(item, &existing->cruft_packs)
250 + existing_packs_mark_retained(item);
251 +}
252 +
253 void existing_packs_retain_cruft(struct existing_packs *existing,
254 struct packed_git *cruft)
255 {
repack.h
+1
@@ -81,6 +81,7 @@ void existing_packs_collect(struct existing_packs *existing,
81 const struct string_list *extra_keep);
82 int existing_packs_has_non_kept(const struct existing_packs *existing);
83 int existing_pack_is_marked_for_deletion(struct string_list_item *item);
84 +void existing_packs_retain_all_cruft(struct existing_packs *existing);
85 void existing_packs_retain_cruft(struct existing_packs *existing,
86 struct packed_git *cruft);
87 void existing_packs_retain_from_geometry(struct existing_packs *existing,