From 27b76d1862b970527cd4abb2a1725138a933a118 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 19 May 2026 11:52:15 +0200 Subject: [PATCH] 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 Signed-off-by: Junio C Hamano --- environment.h | 2 -- setup.c | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/environment.h b/environment.h index 123a71cdc8..9eb97b3869 100644 --- a/environment.h +++ b/environment.h @@ -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 796ac5792f..8965f8ccaf 100644 --- 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);