builtin/repack.c: pass "packdir" when removing packs

builtin/repack.c defines a static "packdir" to instruct pack-objects on where to write any new packfiles. This is also the directory scanned when removing any packfiles which were made redundant by the latest repack. Prepare to move the "existing_packs_remove_redundant" function to its own compilation unit by passing in this information as a parameter to that function. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Oct 15, 2025 at 18:28 UTC 9574e8f31d6d920973213ae5dbab6b77d2deeadf
1 file changed +9 -5
builtin/repack.c
+9 -5
@@ -209,7 +209,8 @@ static void existing_packs_mark_for_deletion(struct existing_packs *existing,
209 }
210
211 static void remove_redundant_packs_1(struct repository *repo,
212 - struct string_list *packs)
212 + struct string_list *packs,
213 + const char *packdir)
214 {
215 struct string_list_item *item;
216 for_each_string_list_item(item, packs) {
@@ -219,10 +220,13 @@ static void remove_redundant_packs_1(struct repository *repo,
220 }
221 }
222
222 -static void existing_packs_remove_redundant(struct existing_packs *existing)
223 +static void existing_packs_remove_redundant(struct existing_packs *existing,
224 + const char *packdir)
225 {
224 - remove_redundant_packs_1(existing->repo, &existing->non_kept_packs);
225 - remove_redundant_packs_1(existing->repo, &existing->cruft_packs);
226 + remove_redundant_packs_1(existing->repo, &existing->non_kept_packs,
227 + packdir);
228 + remove_redundant_packs_1(existing->repo, &existing->cruft_packs,
229 + packdir);
230 }
231
232 static void existing_packs_release(struct existing_packs *existing)
@@ -1659,7 +1663,7 @@ int cmd_repack(int argc,
1663
1664 if (delete_redundant) {
1665 int opts = 0;
1662 - existing_packs_remove_redundant(&existing);
1666 + existing_packs_remove_redundant(&existing, packdir);
1667
1668 if (geometry.split_factor)
1669 geometry_remove_redundant_packs(&geometry, &names,