setup: stop using `the_repository` in `setup_git_env()`

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>

Patrick Steinhardt committed May 19, 2026 at 11:52 UTC 27b76d1862b970527cd4abb2a1725138a933a118
2 files changed +3 -5
environment.h
-2
@@ -147,8 +147,6 @@ void repo_config_values_init(struct repo_config_values *cfg);
147 * Please do not add new global config variables here.
148 */
149 # ifdef USE_THE_REPOSITORY_VARIABLE
150 -void setup_git_env(const char *git_dir);
151 -
150 /*
151 * Returns true iff we have a configured git repository (either via
152 * setup_git_directory, or in the environment via $GIT_DIR).
setup.c
+3 -3
@@ -1074,9 +1074,9 @@ static void setup_git_env_internal(struct repository *repo,
1074 fetch_if_missing = 0;
1075 }
1076
1077 -void setup_git_env(const char *git_dir)
1077 +static void setup_git_env(struct repository *repo, const char *git_dir)
1078 {
1079 - setup_git_env_internal(the_repository, git_dir, false);
1079 + setup_git_env_internal(repo, git_dir, false);
1080 }
1081
1082 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)
1988 const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
1989 if (!gitdir)
1990 gitdir = DEFAULT_GIT_DIR_ENVIRONMENT;
1991 - setup_git_env(gitdir);
1991 + setup_git_env(the_repository, gitdir);
1992 }
1993 if (startup_info->have_repository) {
1994 repo_set_hash_algo(the_repository, repo_fmt.hash_algo);