setup: drop `setup_git_env()`
The `setup_git_env()` function is a trivial wrapper around `setup_git_env_internal()` and has a single call site only. Drop the function. While at it, drop stale documentation in "environment.h" that points to this function, even though it hasn't been exposed to callers outside of "setup.c" since 43ad1047a9 (setup: stop using `the_repository` in `setup_git_env()`, 2026-03-27) anymore. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Jun 4, 2026 at 09:46 UTC
452ad8db6d9155d6c7305d6045d29c49a7cc9c7c
3 files changed
+4
-14
environment.h
+1
-7
@@ -130,13 +130,6 @@ void repo_config_values_init(struct repo_config_values *cfg);
130
* `the_repository`. We should eventually get rid of these and make the
131
* dependency on a repository explicit:
132
*
133
- * - `setup_git_env()` ideally shouldn't exist as it modifies global state,
134
- * namely the environment. The current process shouldn't ever access that
135
- * state via envvars though, but should instead consult a `struct
136
- * repository`. When spawning new processes, we would ideally also pass a
137
- * `struct repository` and then set up the environment variables for the
138
- * child process, only.
139
- *
133
* - `have_git_dir()` should not have to exist at all. Instead, we should
134
* decide on whether or not we have a `struct repository`.
135
*
@@ -147,6 +140,7 @@ void repo_config_values_init(struct repo_config_values *cfg);
140
* Please do not add new global config variables here.
141
*/
142
# ifdef USE_THE_REPOSITORY_VARIABLE
143
+
144
/*
145
* Returns true iff we have a configured git repository (either via
146
* setup_git_directory, or in the environment via $GIT_DIR).
refs.c
+2
-1
@@ -126,7 +126,8 @@ struct ref_namespace_info ref_namespace[] = {
126
* points to the content of another. Unlike the other
127
* ref namespaces, this one can be changed by the
128
* GIT_REPLACE_REF_BASE environment variable. This
129
- * .namespace value will be overwritten in setup_git_env().
129
+ * .namespace value will be overwritten during repository
130
+ * setup.
131
*/
132
.ref = "refs/replace/",
133
.decoration = DECORATION_GRAFTED,
setup.c
+1
-6
@@ -1074,11 +1074,6 @@ static void setup_git_env_internal(struct repository *repo,
1074
fetch_if_missing = 0;
1075
}
1076
1077
-static void setup_git_env(struct repository *repo, const char *git_dir)
1078
-{
1079
- setup_git_env_internal(repo, git_dir, false);
1080
-}
1081
-
1077
static void set_git_dir_1(struct repository *repo, const char *path, bool skip_initializing_odb)
1078
{
1079
xsetenv(GIT_DIR_ENVIRONMENT, path, 1);
@@ -2023,7 +2018,7 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)
2018
const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
2019
if (!gitdir)
2020
gitdir = DEFAULT_GIT_DIR_ENVIRONMENT;
2026
- setup_git_env(repo, gitdir);
2021
+ setup_git_env_internal(repo, gitdir, false);
2022
}
2023
if (startup_info->have_repository) {
2024
repo_set_hash_algo(repo, repo_fmt.hash_algo);