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

[PATCH 00/13] setup: split up repository discovery and setup

From
Patrick Steinhardt <ps@pks.im>
Date
Jun 30, 2026, 11:47 UTC
Message-ID
<20260630-pks-setup-split-discovery-and-setup-v1-0-13864eb5a032@pks.im>
Hi,

this patch series is the next set of refactorings to simplify how we configure repositories in "setup.c".

The setup of the repository is essentially happening in two phases:
  1. We discover the location of the repository as well as its format.
  2. We then use this information to configure the repository.

So far so sensible. In our code base though these two phases are quite intertwined with one another, as we continue to repeatedly call `set_git_dir()` and `set_work_tree()` on the repository as we discover its locations. This makes it hard to follow the logic, and it basically leaves us with a partially-configured repository.

This patch series splits this up into two proper phases that are completely separate from one another. The first phase now populates a `struct repo_discovery` structure, without even having access to any repository. The second phase then takes that structure and configures the repository accordingly.

Ultimately, the motivation of this whole exercise is that eventually we can unify configuration of the repository into `repo_init()` instead of having bits and pieces thereof distributed across "repository.c" and "setup.c".

This series is built on top of v2.55.0 with the following three branches merged into it:

  - ps/refs-onbranch-fixes at d6522d01df (refs: protect against
    chicken-and-egg recursion, 2026-06-25).
  - ps/setup-drop-global-state at 1ceee7431b (treewide: drop
    USE_THE_REPOSITORY_VARIABLE, 2026-06-11).
  - jk/repo-info-path-keys at 3ac28d832a (repo: add path.gitdir with
    absolute and relative suffix formatting, 2026-06-24).
Thanks!
Patrick
---
Patrick Steinhardt (13):
      setup: rename `check_repository_format_gently()`
      setup: mark bogus worktree in `apply_repository_format()`
      setup: unify setup of shallow file
      setup: split up concerns of `setup_git_env_internal()`
      setup: introduce explicit repository discovery
      setup: embed repository format in discovery
      setup: move prefix into repository
      setup: drop static `cwd` variable
      setup: propagate prefix via repository discovery
      setup: make repository discovery self-contained
      setup: drop redundant configuration of `startup_info->have_repository`
      setup: pass worktree to `init_db()`
      setup: mark `set_git_work_tree()` as file-local
 builtin/clone.c        |   8 +-
 builtin/init-db.c      |  34 ++--
 builtin/repo.c         |   8 +-
 builtin/rev-parse.c    |   5 +-
 builtin/update-index.c |   4 +-
 common-init.c          |  20 +++
 git.c                  |   2 +-
 object-name.c          |   4 +-
 repository.c           |   1 +
 repository.h           |   8 +
 setup.c                | 419 ++++++++++++++++++++++++++-----------------------
 setup.h                |   7 +-
 trace.c                |   4 +-
 13 files changed, 283 insertions(+), 241 deletions(-)

--- base-commit: b340fc4c4f3850656b726ff757b42d2020215378 change-id: 20260618-pks-setup-split-discovery-and-setup-d7f23831803c

Next: Patrick Steinhardt
Message 1 of 24 in “setup: split up repository discovery and setup”
  1. 00/13 setup: split up repository discovery and setupPatrick Steinhardt, Jun 30, 2026
  2. 01/13 setup: rename `check_repository_format_gently()`Patrick Steinhardt, Jun 30, 2026
  3. Justin ToblerJul 6, 2026
  4. 02/13 setup: mark bogus worktree in `apply_repository_format()`Patrick Steinhardt, Jun 30, 2026
  5. Junio C HamanoJun 30, 2026
  6. Patrick SteinhardtJul 1, 2026
  7. Justin ToblerJul 6, 2026
  8. Patrick SteinhardtJul 7, 2026
  9. 03/13 setup: unify setup of shallow filePatrick Steinhardt, Jun 30, 2026
  10. Justin ToblerJul 6, 2026
  11. Patrick SteinhardtJul 7, 2026
  12. 04/13 setup: split up concerns of `setup_git_env_internal()`Patrick Steinhardt, Jun 30, 2026
  13. 05/13 setup: introduce explicit repository discoveryPatrick Steinhardt, Jun 30, 2026
  14. Justin ToblerJul 6, 2026
  15. Patrick SteinhardtJul 7, 2026
  16. 06/13 setup: embed repository format in discoveryPatrick Steinhardt, Jun 30, 2026
  17. 07/13 setup: move prefix into repositoryPatrick Steinhardt, Jun 30, 2026
  18. Justin ToblerJul 6, 2026
  19. 08/13 setup: drop static `cwd` variablePatrick Steinhardt, Jun 30, 2026
  20. 09/13 setup: propagate prefix via repository discoveryPatrick Steinhardt, Jun 30, 2026
  21. 10/13 setup: make repository discovery self-containedPatrick Steinhardt, Jun 30, 2026
  22. 11/13 setup: drop redundant configuration of `startup_info->have_repository`Patrick Steinhardt, Jun 30, 2026
  23. 12/13 setup: pass worktree to `init_db()`Patrick Steinhardt, Jun 30, 2026
  24. 13/13 setup: mark `set_git_work_tree()` as file-localPatrick Steinhardt, Jun 30, 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.