]> git.ipfire.org Git - thirdparty/git.git/commitdiff
setup: drop `setup_git_env()`
authorPatrick Steinhardt <ps@pks.im>
Tue, 26 May 2026 05:56:57 +0000 (07:56 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 May 2026 11:07:02 +0000 (20:07 +0900)
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>
environment.h
refs.c
setup.c

index 9eb97b3869c9b1bf9624042dc9435e585aaf11af..ccfcf37bfb9b99a1805355b093008f41b495d196 100644 (file)
@@ -130,13 +130,6 @@ void repo_config_values_init(struct repo_config_values *cfg);
  * `the_repository`. We should eventually get rid of these and make the
  * dependency on a repository explicit:
  *
- *   - `setup_git_env()` ideally shouldn't exist as it modifies global state,
- *     namely the environment. The current process shouldn't ever access that
- *     state via envvars though, but should instead consult a `struct
- *     repository`. When spawning new processes, we would ideally also pass a
- *     `struct repository` and then set up the environment variables for the
- *     child process, only.
- *
  *   - `have_git_dir()` should not have to exist at all. Instead, we should
  *     decide on whether or not we have a `struct repository`.
  *
@@ -147,6 +140,7 @@ void repo_config_values_init(struct repo_config_values *cfg);
  * Please do not add new global config variables here.
  */
 # ifdef USE_THE_REPOSITORY_VARIABLE
+
 /*
  * Returns true iff we have a configured git repository (either via
  * setup_git_directory, or in the environment via $GIT_DIR).
diff --git a/refs.c b/refs.c
index 0f3355d2ee0be123596ca3f33f4bf31035f80a7e..e7070eb7432db00b0996d9343ca99542c1c5238b 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -126,7 +126,8 @@ struct ref_namespace_info ref_namespace[] = {
                 * points to the content of another. Unlike the other
                 * ref namespaces, this one can be changed by the
                 * GIT_REPLACE_REF_BASE environment variable. This
-                * .namespace value will be overwritten in setup_git_env().
+                * .namespace value will be overwritten during repository
+                * setup.
                 */
                .ref = "refs/replace/",
                .decoration = DECORATION_GRAFTED,
diff --git a/setup.c b/setup.c
index d723306dfe5256d4319febdd7d4ae010159b7223..252b4431172265a330cf4b97135e08a34c9e446a 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -1074,11 +1074,6 @@ static void setup_git_env_internal(struct repository *repo,
                fetch_if_missing = 0;
 }
 
-static void setup_git_env(struct repository *repo, const char *git_dir)
-{
-       setup_git_env_internal(repo, git_dir, false);
-}
-
 static void set_git_dir_1(struct repository *repo, const char *path, bool skip_initializing_odb)
 {
        xsetenv(GIT_DIR_ENVIRONMENT, path, 1);
@@ -2023,7 +2018,7 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)
                        const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
                        if (!gitdir)
                                gitdir = DEFAULT_GIT_DIR_ENVIRONMENT;
-                       setup_git_env(repo, gitdir);
+                       setup_git_env_internal(repo, gitdir, false);
                }
                if (startup_info->have_repository) {
                        repo_set_hash_algo(repo, repo_fmt.hash_algo);