git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/8] setup: drop `setup_git_env()`

From
Patrick Steinhardt <ps@pks.im>
Date
May 21, 2026, 07:42 UTC
Message-ID
<20260521-b4-pks-setup-centralize-odb-creation-v1-2-f130d2a7e8ae@pks.im>
In-Reply-To
<20260521-b4-pks-setup-centralize-odb-creation-v1-0-f130d2a7e8ae@pks.im>

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>
---
 environment.h | 8 +-------
 refs.c        | 3 ++-
 setup.c       | 7 +------
 3 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/environment.h b/environment.h
index 9eb97b3869..ccfcf37bfb 100644
--- a/environment.h
+++ b/environment.h
@@ -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 0f3355d2ee..e7070eb743 100644
--- 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 d723306dfe..252b443117 100644
--- 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);
-- 
2.54.0.771.g3ed373ac14.dirty
Previous: Kristoffer HaugsbakkNext: Patrick Steinhardt
Message 7 of 28 in “setup: centralize object database creation”
  1. 0/8 setup: centralize object database creationPatrick Steinhardt, May 21, 2026
  2. 1/8 t0001: plug test gaps for git-init(1) with GIT_OBJECT_DIRECTORYPatrick Steinhardt, May 21, 2026
  3. Junio C HamanoMay 21, 2026
  4. Kristoffer HaugsbakkMay 21, 2026
  5. Patrick SteinhardtMay 22, 2026
  6. Kristoffer HaugsbakkMay 22, 2026
  7. 2/8 setup: drop `setup_git_env()`Patrick Steinhardt, May 21, 2026
  8. 3/8 setup: deduplicate logic to apply repository formatPatrick Steinhardt, May 21, 2026
  9. 4/8 repository: stop initializing the object database in `repo_set_gitdir()`Patrick Steinhardt, May 21, 2026
  10. 5/8 setup: stop creating the object database in `setup_git_env()`Patrick Steinhardt, May 21, 2026
  11. 6/8 setup: stop initializing object database without repositoryPatrick Steinhardt, May 21, 2026
  12. 7/8 repository: stop reading loose object map twice on repo initPatrick Steinhardt, May 21, 2026
  13. 8/8 setup: construct object database in `apply_repository_format()`Patrick Steinhardt, May 21, 2026
  14. Junio C HamanoMay 21, 2026
  15. Patrick SteinhardtMay 22, 2026
  16. Junio C HamanoMay 22, 2026
  17. Patrick SteinhardtMay 22, 2026
  18. 0/8 setup: centralize object database creationPatrick Steinhardt, Jun 4, 2026
  19. 1/8 t0001: plug test gaps for git-init(1) with GIT_OBJECT_DIRECTORYPatrick Steinhardt, Jun 4, 2026
  20. 2/8 setup: drop `setup_git_env()`Patrick Steinhardt, Jun 4, 2026
  21. 3/8 setup: deduplicate logic to apply repository formatPatrick Steinhardt, Jun 4, 2026
  22. 4/8 repository: stop initializing the object database in `repo_set_gitdir()`Patrick Steinhardt, Jun 4, 2026
  23. 5/8 setup: stop creating the object database in `setup_git_env()`Patrick Steinhardt, Jun 4, 2026
  24. 6/8 setup: stop initializing object database without repositoryPatrick Steinhardt, Jun 4, 2026
  25. 7/8 repository: stop reading loose object map twice on repo initPatrick Steinhardt, Jun 4, 2026
  26. 8/8 setup: construct object database in `apply_repository_format()`Patrick Steinhardt, Jun 4, 2026
  27. Karthik NayakJun 5, 2026
  28. Junio C HamanoJun 8, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.