repack: unconditionally exclude non-kept packs

In `write_cruft_pack()`, we handle excluding objects found in non-kept packs from being included in the cruft pack via two code paths: * When using '--combine-cruft-below-size' (provided that we are not expiring cruft objects), we use the aptly-named `combine_small_cruft_packs()` function. * In all other cases, we handle it directly in the 'else' branch of the same conditional. Simplify this by moving the non-kept pack exclusion out of the conditional entirely, so that non-kept packs are always excluded regardless of whether we are combining small cruft packs or not. This is a preparatory refactor for a subsequent change that will use the pack_geometry struct when available to determine which non-kept packs to exclude. 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 1a9c49e4bb07bd26d2f591c746ab9c9c82423533
1 file changed +4 -10
repack-cruft.c
+4 -10
@@ -9,7 +9,6 @@ static void combine_small_cruft_packs(FILE *in, off_t combine_cruft_below_size,
9 {
10 struct packed_git *p;
11 struct strbuf buf = STRBUF_INIT;
12 - size_t i;
12
13 repo_for_each_pack(existing->repo, p) {
14 if (!(p->is_cruft && p->pack_local))
@@ -30,10 +29,6 @@ static void combine_small_cruft_packs(FILE *in, off_t combine_cruft_below_size,
29 }
30 }
31
33 - for (i = 0; i < existing->non_kept_packs.nr; i++)
34 - fprintf(in, "-%s.pack\n",
35 - existing->non_kept_packs.items[i].string);
36 -
32 strbuf_release(&buf);
33 }
34
@@ -80,15 +75,14 @@ int write_cruft_pack(const struct write_pack_opts *opts,
75 in = xfdopen(cmd.in, "w");
76 for_each_string_list_item(item, names)
77 fprintf(in, "%s-%s.pack\n", pack_prefix, item->string);
83 - if (combine_cruft_below_size && !cruft_expiration) {
78 + if (combine_cruft_below_size && !cruft_expiration)
79 combine_small_cruft_packs(in, combine_cruft_below_size,
80 existing);
86 - } else {
87 - for_each_string_list_item(item, &existing->non_kept_packs)
88 - fprintf(in, "-%s.pack\n", item->string);
81 + else
82 for_each_string_list_item(item, &existing->cruft_packs)
83 fprintf(in, "-%s.pack\n", item->string);
91 - }
84 + for_each_string_list_item(item, &existing->non_kept_packs)
85 + fprintf(in, "-%s.pack\n", item->string);
86 for_each_string_list_item(item, &existing->kept_packs)
87 fprintf(in, "%s.pack\n", item->string);
88 fclose(in);