builtin/repack.c: avoid "the_repository" in `cmd_repack()`
Reduce builtin/repack.c's reliance on `the_repository` by using the currently-UNUSED "repo" parameter within cmd_repack(). The following commits will continue to reduce the usage of the_repository in other places within builtin/repack.c. 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
20b4eeddce165f11d7c5bffb1ecb69017df4a05e
1 file changed
+16
-15
builtin/repack.c
+16
-15
@@ -1247,7 +1247,7 @@ static const char *find_pack_prefix(const char *packdir, const char *packtmp)
1247
int cmd_repack(int argc,
1248
const char **argv,
1249
const char *prefix,
1250
- struct repository *repo UNUSED)
1250
+ struct repository *repo)
1251
{
1252
struct child_process cmd = CHILD_PROCESS_INIT;
1253
struct string_list_item *item;
@@ -1344,7 +1344,7 @@ int cmd_repack(int argc,
1344
1345
list_objects_filter_init(&po_args.filter_options);
1346
1347
- repo_config(the_repository, repack_config, &cruft_po_args);
1347
+ repo_config(repo, repack_config, &cruft_po_args);
1348
1349
argc = parse_options(argc, argv, prefix, builtin_repack_options,
1350
git_repack_usage, 0);
@@ -1354,7 +1354,7 @@ int cmd_repack(int argc,
1354
po_args.depth = xstrdup_or_null(opt_depth);
1355
po_args.threads = xstrdup_or_null(opt_threads);
1356
1357
- if (delete_redundant && the_repository->repository_format_precious_objects)
1357
+ if (delete_redundant && repo->repository_format_precious_objects)
1358
die(_("cannot delete packs in a precious-objects repo"));
1359
1360
die_for_incompatible_opt3(unpack_unreachable || (pack_everything & LOOSEN_UNREACHABLE), "-A",
@@ -1376,7 +1376,7 @@ int cmd_repack(int argc,
1376
die(_(incremental_bitmap_conflict_error));
1377
1378
if (write_bitmaps && po_args.local &&
1379
- odb_has_alternates(the_repository->objects)) {
1379
+ odb_has_alternates(repo->objects)) {
1380
/*
1381
* When asked to do a local repack, but we have
1382
* packfiles that are inherited from an alternate, then
@@ -1391,7 +1391,8 @@ int cmd_repack(int argc,
1391
if (write_midx && write_bitmaps) {
1392
struct strbuf path = STRBUF_INIT;
1393
1394
- strbuf_addf(&path, "%s/%s_XXXXXX", repo_get_object_directory(the_repository),
1394
+ strbuf_addf(&path, "%s/%s_XXXXXX",
1395
+ repo_get_object_directory(repo),
1396
"bitmap-ref-tips");
1397
1398
refs_snapshot = xmks_tempfile(path.buf);
@@ -1400,7 +1401,7 @@ int cmd_repack(int argc,
1401
strbuf_release(&path);
1402
}
1403
1403
- packdir = mkpathdup("%s/pack", repo_get_object_directory(the_repository));
1404
+ packdir = mkpathdup("%s/pack", repo_get_object_directory(repo));
1405
packtmp_name = xstrfmt(".tmp-%d-pack", (int)getpid());
1406
packtmp = mkpathdup("%s/%s", packdir, packtmp_name);
1407
@@ -1439,7 +1440,7 @@ int cmd_repack(int argc,
1440
strvec_push(&cmd.args, "--reflog");
1441
strvec_push(&cmd.args, "--indexed-objects");
1442
}
1442
- if (repo_has_promisor_remote(the_repository))
1443
+ if (repo_has_promisor_remote(repo))
1444
strvec_push(&cmd.args, "--exclude-promisor-objects");
1445
if (!write_midx) {
1446
if (write_bitmaps > 0)
@@ -1535,7 +1536,7 @@ int cmd_repack(int argc,
1536
* midx_has_unknown_packs() will make the decision for
1537
* us.
1538
*/
1538
- if (!get_multi_pack_index(the_repository->objects->sources))
1539
+ if (!get_multi_pack_index(repo->objects->sources))
1540
midx_must_contain_cruft = 1;
1541
}
1542
@@ -1618,9 +1619,9 @@ int cmd_repack(int argc,
1619
1620
string_list_sort(&names);
1621
1621
- if (get_multi_pack_index(the_repository->objects->sources)) {
1622
+ if (get_multi_pack_index(repo->objects->sources)) {
1623
struct multi_pack_index *m =
1623
- get_multi_pack_index(the_repository->objects->sources);
1624
+ get_multi_pack_index(repo->objects->sources);
1625
1626
ALLOC_ARRAY(midx_pack_names,
1627
m->num_packs + m->num_packs_in_base);
@@ -1631,7 +1632,7 @@ int cmd_repack(int argc,
1632
xstrdup(m->pack_names[i]);
1633
}
1634
1634
- close_object_store(the_repository->objects);
1635
+ close_object_store(repo->objects);
1636
1637
/*
1638
* Ok we have prepared all new packfiles.
@@ -1688,7 +1689,7 @@ int cmd_repack(int argc,
1689
goto cleanup;
1690
}
1691
1691
- odb_reprepare(the_repository->objects);
1692
+ odb_reprepare(repo->objects);
1693
1694
if (delete_redundant) {
1695
int opts = 0;
@@ -1704,18 +1705,18 @@ int cmd_repack(int argc,
1705
if (!keep_unreachable &&
1706
(!(pack_everything & LOOSEN_UNREACHABLE) ||
1707
unpack_unreachable) &&
1707
- is_repository_shallow(the_repository))
1708
+ is_repository_shallow(repo))
1709
prune_shallow(PRUNE_QUICK);
1710
}
1711
1712
if (run_update_server_info)
1712
- update_server_info(the_repository, 0);
1713
+ update_server_info(repo, 0);
1714
1715
if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0)) {
1716
unsigned flags = 0;
1717
if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL, 0))
1718
flags |= MIDX_WRITE_INCREMENTAL;
1718
- write_midx_file(the_repository->objects->sources,
1719
+ write_midx_file(repo->objects->sources,
1720
NULL, NULL, flags);
1721
}
1722