builtin/repack.c: avoid "the_repository" when removing packs
The 'remove_redundant_pack()' function uses "the_repository" to obtain, and optionally remove, the repository's MIDX. Instead of relying on "the_repository", pass around a "struct repository *" parameter through its callers, and use that instead. 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:27 UTC
03015747584e9f96c7ad6b57ecd99aa694312333
1 file changed
+10
-8
builtin/repack.c
+10
-8
@@ -221,33 +221,35 @@ static void mark_packs_for_deletion(struct existing_packs *existing,
221
mark_packs_for_deletion_1(names, &existing->cruft_packs);
222
}
223
224
-static void remove_redundant_pack(const char *dir_name, const char *base_name)
224
+static void remove_redundant_pack(struct repository *repo,
225
+ const char *dir_name, const char *base_name)
226
{
227
struct strbuf buf = STRBUF_INIT;
227
- struct odb_source *source = the_repository->objects->sources;
228
+ struct odb_source *source = repo->objects->sources;
229
struct multi_pack_index *m = get_multi_pack_index(source);
230
strbuf_addf(&buf, "%s.pack", base_name);
231
if (m && source->local && midx_contains_pack(m, buf.buf))
231
- clear_midx_file(the_repository);
232
+ clear_midx_file(repo);
233
strbuf_insertf(&buf, 0, "%s/", dir_name);
234
unlink_pack_path(buf.buf, 1);
235
strbuf_release(&buf);
236
}
237
237
-static void remove_redundant_packs_1(struct string_list *packs)
238
+static void remove_redundant_packs_1(struct repository *repo,
239
+ struct string_list *packs)
240
{
241
struct string_list_item *item;
242
for_each_string_list_item(item, packs) {
243
if (!pack_is_marked_for_deletion(item))
244
continue;
243
- remove_redundant_pack(packdir, item->string);
245
+ remove_redundant_pack(repo, packdir, item->string);
246
}
247
}
248
249
static void remove_redundant_existing_packs(struct existing_packs *existing)
250
{
249
- remove_redundant_packs_1(&existing->non_kept_packs);
250
- remove_redundant_packs_1(&existing->cruft_packs);
251
+ remove_redundant_packs_1(existing->repo, &existing->non_kept_packs);
252
+ remove_redundant_packs_1(existing->repo, &existing->cruft_packs);
253
}
254
255
static void existing_packs_release(struct existing_packs *existing)
@@ -685,7 +687,7 @@ static void geometry_remove_redundant_packs(struct pack_geometry *geometry,
687
(string_list_has_string(&existing->kept_packs, buf.buf)))
688
continue;
689
688
- remove_redundant_pack(packdir, buf.buf);
690
+ remove_redundant_pack(existing->repo, packdir, buf.buf);
691
}
692
693
strbuf_release(&buf);