]> git.ipfire.org Git - thirdparty/git.git/commitdiff
setup: stop using `the_repository` in `create_reference_database()`
authorPatrick Steinhardt <ps@pks.im>
Mon, 20 Apr 2026 08:22:47 +0000 (10:22 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Apr 2026 16:53:58 +0000 (09:53 -0700)
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>
builtin/clone.c
setup.c
setup.h

index 663ef0b524a11e91e4d836004486354bc457b9b2..d8640222149c8c143427e3049954425c898b12a8 100644 (file)
@@ -1442,7 +1442,7 @@ int cmd_clone(int argc,
        hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));
        initialize_repository_version(the_repository, hash_algo, the_repository->ref_storage_format, 1);
        repo_set_hash_algo(the_repository, hash_algo);
-       create_reference_database(NULL, 1);
+       create_reference_database(the_repository, NULL, 1);
 
        /*
         * Before fetching from the remote, download and install bundle
diff --git a/setup.c b/setup.c
index f1d640ea74ba823884b31726e36052a3d120ecaf..8616f5e619ea17ba2995e4f924b74c8813e13d87 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -2459,13 +2459,14 @@ static int is_reinit(struct repository *repo)
        return ret;
 }
 
-void create_reference_database(const char *initial_branch, int quiet)
+void create_reference_database(struct repository *repo,
+                              const char *initial_branch, int quiet)
 {
        struct strbuf err = STRBUF_INIT;
        char *to_free = NULL;
-       int reinit = is_reinit(the_repository);
+       int reinit = is_reinit(repo);
 
-       if (ref_store_create_on_disk(get_main_ref_store(the_repository), 0, &err))
+       if (ref_store_create_on_disk(get_main_ref_store(repo), 0, &err))
                die("failed to set up refs db: %s", err.buf);
 
        /*
@@ -2477,14 +2478,14 @@ void create_reference_database(const char *initial_branch, int quiet)
 
                if (!initial_branch)
                        initial_branch = to_free =
-                               repo_default_branch_name(the_repository, quiet);
+                               repo_default_branch_name(repo, quiet);
 
                ref = xstrfmt("refs/heads/%s", initial_branch);
                if (check_refname_format(ref, 0) < 0)
                        die(_("invalid initial branch name: '%s'"),
                            initial_branch);
 
-               if (refs_update_symref(get_main_ref_store(the_repository), "HEAD", ref, NULL) < 0)
+               if (refs_update_symref(get_main_ref_store(repo), "HEAD", ref, NULL) < 0)
                        exit(1);
                free(ref);
        }
@@ -2821,7 +2822,7 @@ int init_db(const char *git_dir, const char *real_git_dir,
                                      &repo_fmt, init_shared_repository);
 
        if (!(flags & INIT_DB_SKIP_REFDB))
-               create_reference_database(initial_branch, flags & INIT_DB_QUIET);
+               create_reference_database(the_repository, initial_branch, flags & INIT_DB_QUIET);
        create_object_directory(the_repository);
 
        if (repo_settings_get_shared_repository(the_repository)) {
diff --git a/setup.h b/setup.h
index c33b675ccfd95f2afac9a5d6311ad8b78de309a4..21737e9bd69108349779a077830afb3711b21873 100644 (file)
--- a/setup.h
+++ b/setup.h
@@ -236,7 +236,7 @@ void initialize_repository_version(struct repository *repo,
                                   int hash_algo,
                                   enum ref_storage_format ref_storage_format,
                                   int reinit);
-void create_reference_database(const char *initial_branch, int quiet);
+void create_reference_database(struct repository *repo, const char *initial_branch, int quiet);
 
 /*
  * NOTE NOTE NOTE!!