]> git.ipfire.org Git - thirdparty/git.git/commitdiff
setup: stop using `the_repository` in `initialize_repository_version()`
authorPatrick Steinhardt <ps@pks.im>
Mon, 20 Apr 2026 08:22:46 +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 `initialize_repository_version()` 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
refs.c
setup.c
setup.h

index 16cd7b029b09677fbeba0b0e7e0528e559f50ed6..663ef0b524a11e91e4d836004486354bc457b9b2 100644 (file)
@@ -1227,7 +1227,7 @@ int cmd_clone(int argc,
         *
         * This is sufficient for Git commands to discover the Git directory.
         */
-       initialize_repository_version(GIT_HASH_UNKNOWN,
+       initialize_repository_version(the_repository, GIT_HASH_UNKNOWN,
                                      the_repository->ref_storage_format, 1);
 
        refs_create_refdir_stubs(the_repository, git_dir, NULL);
@@ -1440,7 +1440,7 @@ int cmd_clone(int argc,
         * ours to the same thing.
         */
        hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));
-       initialize_repository_version(hash_algo, the_repository->ref_storage_format, 1);
+       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);
 
diff --git a/refs.c b/refs.c
index e66cf4861d7ec5d23e8fb7b6ec8531d481a85813..6a49ef8a1cd56b42f0fc039779e955ab4e89325f 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -3450,7 +3450,7 @@ int repo_migrate_ref_storage_format(struct repository *repo,
         * repository format so that clients will use the new ref store.
         * We also need to swap out the repository's main ref store.
         */
-       initialize_repository_version(hash_algo_by_ptr(repo->hash_algo), format, 1);
+       initialize_repository_version(the_repository, hash_algo_by_ptr(repo->hash_algo), format, 1);
 
        /*
         * Unset the old ref store and release it. `get_main_ref_store()` will
diff --git a/setup.c b/setup.c
index 803d482849807b1fd2464f38a8fb16c6aa210b22..f1d640ea74ba823884b31726e36052a3d120ecaf 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -2376,7 +2376,8 @@ static int needs_work_tree_config(const char *git_dir, const char *work_tree)
        return 1;
 }
 
-void initialize_repository_version(int hash_algo,
+void initialize_repository_version(struct repository *repo,
+                                  int hash_algo,
                                   enum ref_storage_format ref_storage_format,
                                   int reinit)
 {
@@ -2393,35 +2394,35 @@ void initialize_repository_version(int hash_algo,
         */
        if (hash_algo != GIT_HASH_SHA1_LEGACY ||
            ref_storage_format != REF_STORAGE_FORMAT_FILES ||
-           the_repository->ref_storage_payload)
+           repo->ref_storage_payload)
                target_version = GIT_REPO_VERSION_READ;
 
        if (hash_algo != GIT_HASH_SHA1_LEGACY && hash_algo != GIT_HASH_UNKNOWN)
-               repo_config_set(the_repository, "extensions.objectformat",
+               repo_config_set(repo, "extensions.objectformat",
                                hash_algos[hash_algo].name);
        else if (reinit)
-               repo_config_set_gently(the_repository, "extensions.objectformat", NULL);
+               repo_config_set_gently(repo, "extensions.objectformat", NULL);
 
-       if (the_repository->ref_storage_payload) {
+       if (repo->ref_storage_payload) {
                struct strbuf ref_uri = STRBUF_INIT;
 
                strbuf_addf(&ref_uri, "%s://%s",
                            ref_storage_format_to_name(ref_storage_format),
-                           the_repository->ref_storage_payload);
-               repo_config_set(the_repository, "extensions.refstorage", ref_uri.buf);
+                           repo->ref_storage_payload);
+               repo_config_set(repo, "extensions.refstorage", ref_uri.buf);
                strbuf_release(&ref_uri);
        } else if (ref_storage_format != REF_STORAGE_FORMAT_FILES) {
-               repo_config_set(the_repository, "extensions.refstorage",
+               repo_config_set(repo, "extensions.refstorage",
                                ref_storage_format_to_name(ref_storage_format));
        } else if (reinit) {
-               repo_config_set_gently(the_repository, "extensions.refstorage", NULL);
+               repo_config_set_gently(repo, "extensions.refstorage", NULL);
        }
 
        if (reinit) {
                struct strbuf config = STRBUF_INIT;
                struct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;
 
-               repo_common_path_append(the_repository, &config, "config");
+               repo_common_path_append(repo, &config, "config");
                read_repository_format(&repo_fmt, config.buf);
 
                if (repo_fmt.v1_only_extensions.nr)
@@ -2431,17 +2432,17 @@ void initialize_repository_version(int hash_algo,
                clear_repository_format(&repo_fmt);
        }
 
-       repo_config_get_bool(the_repository, "init.defaultSubmodulePathConfig",
+       repo_config_get_bool(repo, "init.defaultSubmodulePathConfig",
                             &default_submodule_path_config);
        if (default_submodule_path_config) {
                /* extensions.submodulepathconfig requires at least version 1 */
                if (target_version == 0)
                        target_version = 1;
-               repo_config_set(the_repository, "extensions.submodulepathconfig", "true");
+               repo_config_set(repo, "extensions.submodulepathconfig", "true");
        }
 
        strbuf_addf(&repo_version, "%d", target_version);
-       repo_config_set(the_repository, "core.repositoryformatversion", repo_version.buf);
+       repo_config_set(repo, "core.repositoryformatversion", repo_version.buf);
 
        strbuf_release(&repo_version);
 }
@@ -2542,7 +2543,7 @@ static int create_default_files(struct repository *repo,
                adjust_shared_perm(repo, repo_get_git_dir(repo));
        }
 
-       initialize_repository_version(fmt->hash_algo, fmt->ref_storage_format, reinit);
+       initialize_repository_version(repo, fmt->hash_algo, fmt->ref_storage_format, reinit);
 
        /* Check filemode trustability */
        repo_git_path_replace(repo, &path, "config");
diff --git a/setup.h b/setup.h
index a820041af05ffbd83d0d640dbc8da104bd78bf2a..c33b675ccfd95f2afac9a5d6311ad8b78de309a4 100644 (file)
--- a/setup.h
+++ b/setup.h
@@ -232,7 +232,8 @@ int init_db(const char *git_dir, const char *real_git_dir,
            enum ref_storage_format ref_storage_format,
            const char *initial_branch, int init_shared_repository,
            unsigned int flags);
-void initialize_repository_version(int hash_algo,
+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);