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

[PATCH v2 0/8] setup: centralize object database creation

From
Patrick Steinhardt <ps@pks.im>
Date
May 26, 2026, 05:56 UTC
Message-ID
<20260526-b4-pks-setup-centralize-odb-creation-v2-0-2fa5b385c13e@pks.im>
In-Reply-To
<20260521-b4-pks-setup-centralize-odb-creation-v1-0-f130d2a7e8ae@pks.im>
Hi,

this small patch series refactors the logic for how we discover and configure repositories. Most importantly, this involves the following two steps:

  1. We unify the logic to apply the repository format, which is
     currently open-coded across multiple sites. These sites have
     already diverged, where some repository extensions are not
     consistently applied.
  2. We then centralize creation of the object database to happen at the
     same time we apply the repository format.

The end result is that we apply the repository format exactly once, and that's also the point in time where we can finalize the setup of the repo's data structures as we know about all details of the repo at that time. Ultimately, this makes it trivial to introduce the "objectStorage" extension, even though that's not part of this patch series.

The series is built on top of aec3f58750 (Sync with 'maint', 2026-05-21) with ps/setup-wo-the-repository at df69f40c34 (setup: stop using `the_repository` in `init_db()`, 2026-05-19) merged into it.

Changes in v2:
  - Commit message improvements.
  - Link to v1: https://patch.msgid.link/20260521-b4-pks-setup-centralize-odb-creation-v1-0-f130d2a7e8ae@pks.im
Thanks!
Patrick
---
Patrick Steinhardt (8):
      t0001: plug test gaps for git-init(1) with GIT_OBJECT_DIRECTORY
      setup: drop `setup_git_env()`
      setup: deduplicate logic to apply repository format
      repository: stop initializing the object database in `repo_set_gitdir()`
      setup: stop creating the object database in `setup_git_env()`
      setup: stop initializing object database without repository
      repository: stop reading loose object map twice on repo init
      setup: construct object database in `apply_repository_format()`
 commit-graph.c  |   4 +-
 environment.h   |   8 +---
 refs.c          |   3 +-
 repository.c    |  40 +++++------------
 repository.h    |   3 --
 setup.c         | 130 +++++++++++++++++++++++++++++++-------------------------
 setup.h         |  19 +++++++++
 t/t0001-init.sh |  10 +++++
 8 files changed, 117 insertions(+), 100 deletions(-)
Range-diff versus v1:
1:  dd1fcc7096 ! 1:  14521d16e6 t0001: plug test gaps for git-init(1) with GIT_OBJECT_DIRECTORY
    @@ Commit message
         t0001: plug test gaps for git-init(1) with GIT_OBJECT_DIRECTORY
     
         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
    +    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" enviroment variable. When set, the
    +    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:
    @@ Commit message
           directory is used.
     
         Curiously enough though we don't seem to have any tests that exercise
    -    this directly, and thus a subsequent commit inadvertently broke this
    -    expectation.
    +    this directly, and thus a subsequent commit inadvertently would have
    +    broken this expectation.
     
         Plug this test gap.
     
2:  b150ecc19f = 2:  9c099e511b setup: drop `setup_git_env()`
3:  9a638f22e8 = 3:  3bbddc1021 setup: deduplicate logic to apply repository format
4:  60f4647bc2 = 4:  5f531305b2 repository: stop initializing the object database in `repo_set_gitdir()`
5:  6d4013ac62 = 5:  57e1de3a36 setup: stop creating the object database in `setup_git_env()`
6:  f4465744a1 = 6:  944dbaeaf8 setup: stop initializing object database without repository
7:  4b6c61be63 = 7:  2eb5646afc repository: stop reading loose object map twice on repo init
8:  54e3a338e5 ! 8:  5322ce123e setup: construct object database in `apply_repository_format()`
    @@ Commit message
         variables GIT_OBJECT_DIRECTORY and GIT_ALTERNATE_OBJECT_DIRECTORIES into
         the repository format, as well. This allows the caller more flexibility
         around whether or not those environment variables are being honored, as
    -    we do do want to respect them in "setup.c", but not in "repository.c".
    +    we want to respect them in "setup.c", but not in "repository.c".
     
         Signed-off-by: Patrick Steinhardt <ps@pks.im>
     

--- base-commit: 3398daa441965513c48744305d33bd36404547d6 change-id: 20260519-b4-pks-setup-centralize-odb-creation-3479c53fb11d

Next: Patrick Steinhardt
Message 1 of 17 in “setup: centralize object database creation”
  1. 0/8 setup: centralize object database creationPatrick Steinhardt, May 26, 2026
  2. 1/8 t0001: plug test gaps for git-init(1) with GIT_OBJECT_DIRECTORYPatrick Steinhardt, May 26, 2026
  3. Karthik NayakJun 3, 2026
  4. 2/8 setup: drop `setup_git_env()`Patrick Steinhardt, May 26, 2026
  5. 3/8 setup: deduplicate logic to apply repository formatPatrick Steinhardt, May 26, 2026
  6. Karthik NayakJun 3, 2026
  7. Patrick SteinhardtJun 4, 2026
  8. 5/8 setup: stop creating the object database in `setup_git_env()`Patrick Steinhardt, May 26, 2026
  9. Karthik NayakJun 3, 2026
  10. 4/8 repository: stop initializing the object database in `repo_set_gitdir()`Patrick Steinhardt, May 26, 2026
  11. Karthik NayakJun 3, 2026
  12. Patrick SteinhardtJun 4, 2026
  13. 6/8 setup: stop initializing object database without repositoryPatrick Steinhardt, May 26, 2026
  14. 7/8 repository: stop reading loose object map twice on repo initPatrick Steinhardt, May 26, 2026
  15. 8/8 setup: construct object database in `apply_repository_format()`Patrick Steinhardt, May 26, 2026
  16. Karthik NayakJun 3, 2026
  17. Patrick SteinhardtJun 4, 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.