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

[PATCH v3 1/8] t0001: plug test gaps for git-init(1) with GIT_OBJECT_DIRECTORY

From
Patrick Steinhardt <ps@pks.im>
Date
Jun 4, 2026, 07:46 UTC
Message-ID
<20260604-b4-pks-setup-centralize-odb-creation-v3-1-0691834f318a@pks.im>
In-Reply-To
<20260604-b4-pks-setup-centralize-odb-creation-v3-0-0691834f318a@pks.im>

In subsequent commits we'll rework how we set up the repository. This is a somewhat intricate and thus fragile sequence; there's many things that can go subtly wrong, and there are lots of interesting interactions that one can discover.

One such discovered edge case was the interaction between git-init(1) and the "GIT_OBJECT_DIRECTORY" environment variable. When set, the behaviour is that the object directory should be created at the path that the variable points to. This behaviour is documented as such in its man page:

  If the object storage directory is specified via the
  GIT_OBJECT_DIRECTORY environment variable then the sha1 directories
  are created underneath; otherwise, the default $GIT_DIR/objects
  directory is used.

Curiously enough though we don't seem to have any tests that exercise this directly, and thus a subsequent commit inadvertently would have broken this expectation.

Plug this test gap.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/t0001-init.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index e4d32bb4d2..e89feca544 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -980,4 +980,14 @@ test_expect_success 're-init reads matching includeIf.onbranch' '
 	test_cmp expect err
 '
 
+test_expect_success 'init honors GIT_OBJECT_DIRECTORY' '
+	test_when_finished "rm -rf init-objdir custom-odb" &&
+	mkdir custom-odb &&
+	env GIT_OBJECT_DIRECTORY="$(pwd)/custom-odb" \
+		git init init-objdir &&
+	test_path_is_missing init-objdir/.git/objects/pack &&
+	test_path_is_dir custom-odb/pack &&
+	test_path_is_dir custom-odb/info
+'
+
 test_done
-- 
2.54.0.1064.gd145956f57.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 19 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.