setup: stop using `the_repository` in `create_reference_database()`
Stop using `the_repository` in `create_reference_database()` and instead accept the repository as a parameter. The injection of `the_repository` is thus bumped one level higher, where callers now pass it in explicitly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
May 19, 2026 at 11:52 UTC
15053894cb55afdd50b938df9c89d98d2af0548a
3 files changed
+9
-8
builtin/clone.c
+1
-1
@@ -1444,7 +1444,7 @@ int cmd_clone(int argc,
1444
hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));
1445
initialize_repository_version(the_repository, hash_algo, the_repository->ref_storage_format, 1);
1446
repo_set_hash_algo(the_repository, hash_algo);
1447
- create_reference_database(NULL, 1);
1447
+ create_reference_database(the_repository, NULL, 1);
1448
1449
/*
1450
* Before fetching from the remote, download and install bundle
setup.c
+7
-6
@@ -2468,13 +2468,14 @@ static int is_reinit(struct repository *repo)
2468
return ret;
2469
}
2470
2471
-void create_reference_database(const char *initial_branch, int quiet)
2471
+void create_reference_database(struct repository *repo,
2472
+ const char *initial_branch, int quiet)
2473
{
2474
struct strbuf err = STRBUF_INIT;
2475
char *to_free = NULL;
2475
- int reinit = is_reinit(the_repository);
2476
+ int reinit = is_reinit(repo);
2477
2477
- if (ref_store_create_on_disk(get_main_ref_store(the_repository), 0, &err))
2478
+ if (ref_store_create_on_disk(get_main_ref_store(repo), 0, &err))
2479
die("failed to set up refs db: %s", err.buf);
2480
2481
/*
@@ -2486,14 +2487,14 @@ void create_reference_database(const char *initial_branch, int quiet)
2487
2488
if (!initial_branch)
2489
initial_branch = to_free =
2489
- repo_default_branch_name(the_repository, quiet);
2490
+ repo_default_branch_name(repo, quiet);
2491
2492
ref = xstrfmt("refs/heads/%s", initial_branch);
2493
if (check_refname_format(ref, 0) < 0)
2494
die(_("invalid initial branch name: '%s'"),
2495
initial_branch);
2496
2496
- if (refs_update_symref(get_main_ref_store(the_repository), "HEAD", ref, NULL) < 0)
2497
+ if (refs_update_symref(get_main_ref_store(repo), "HEAD", ref, NULL) < 0)
2498
exit(1);
2499
free(ref);
2500
}
@@ -2830,7 +2831,7 @@ int init_db(const char *git_dir, const char *real_git_dir,
2831
&repo_fmt, init_shared_repository);
2832
2833
if (!(flags & INIT_DB_SKIP_REFDB))
2833
- create_reference_database(initial_branch, flags & INIT_DB_QUIET);
2834
+ create_reference_database(the_repository, initial_branch, flags & INIT_DB_QUIET);
2835
create_object_directory(the_repository);
2836
2837
if (repo_settings_get_shared_repository(the_repository)) {
setup.h
+1
-1
@@ -236,7 +236,7 @@ void initialize_repository_version(struct repository *repo,
236
int hash_algo,
237
enum ref_storage_format ref_storage_format,
238
int reinit);
239
-void create_reference_database(const char *initial_branch, int quiet);
239
+void create_reference_database(struct repository *repo, const char *initial_branch, int quiet);
240
241
/*
242
* NOTE NOTE NOTE!!