]> git.ipfire.org Git - thirdparty/git.git/commitdiff
setup: stop using `the_repository` in `setup_git_env()`
authorPatrick Steinhardt <ps@pks.im>
Tue, 19 May 2026 09:52:15 +0000 (11:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 May 2026 10:36:24 +0000 (19:36 +0900)
Stop using `the_repository` in `setup_git_env()` 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.

Furthermore, the function is never used outside of "setup.c". Drop the
declaration in "environment.h" and make it static.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
environment.h
setup.c

index 123a71cdc8d14ed3386b925bac2827ff52f554b2..9eb97b3869c9b1bf9624042dc9435e585aaf11af 100644 (file)
@@ -147,8 +147,6 @@ void repo_config_values_init(struct repo_config_values *cfg);
  * Please do not add new global config variables here.
  */
 # ifdef USE_THE_REPOSITORY_VARIABLE
-void setup_git_env(const char *git_dir);
-
 /*
  * Returns true iff we have a configured git repository (either via
  * setup_git_directory, or in the environment via $GIT_DIR).
diff --git a/setup.c b/setup.c
index 796ac5792fe9fded941fb7ccf873f2bd2607c88d..8965f8ccaf20b18e9accf8d894531cc9321564f0 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -1074,9 +1074,9 @@ static void setup_git_env_internal(struct repository *repo,
                fetch_if_missing = 0;
 }
 
-void setup_git_env(const char *git_dir)
+static void setup_git_env(struct repository *repo, const char *git_dir)
 {
-       setup_git_env_internal(the_repository, git_dir, false);
+       setup_git_env_internal(repo, git_dir, false);
 }
 
 static void set_git_dir_1(struct repository *repo, const char *path, bool skip_initializing_odb)
@@ -1988,7 +1988,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
                        const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
                        if (!gitdir)
                                gitdir = DEFAULT_GIT_DIR_ENVIRONMENT;
-                       setup_git_env(gitdir);
+                       setup_git_env(the_repository, gitdir);
                }
                if (startup_info->have_repository) {
                        repo_set_hash_algo(the_repository, repo_fmt.hash_algo);