Re: [PATCH 05/13] setup: introduce explicit repository discovery
From: Justin Tobler <hidden>
Date: 2026-07-06 22:20:04
On 26/06/30 01:47PM, Patrick Steinhardt wrote:
When setting up the global repository we intermix repository discovery
and repository configuration: we repeatedly call `set_git_work_tree()`
and `apply_and_export_relative_gitdir()` until we're happy with the
result. The result of this is then a partially-configured repository
that we use for further setup.
This process is quite hard to follow, as it's never quite clear which
parts of the repository have been configured already and which haven't.
Furthermore, it means that the repository configuration is distributed
across many different places instead of having it neatly contained in a
single location. Ultimately, this is the reason that we cannot use a
central function like `repo_init()`.
Refactor the logic so that we stop partially-configuring a repository
and instead populate a new `struct repo_discovery`. This allow us to
essentially split repository setup into two phases:
- The first phase only figures out parameters required to configure
the repository.
- The second phase then takes these parameters and applies them to the
repository.Ok so `struct repo_discovery` is just an intermediate structure to store all the repository configuration so we can apply it all at once. Makes sense.
Like this, we'll never end up with a partially-configured repository and can eventually extend `repo_init()` to handle the full initialization for us.
So IIUC the expectation here would be for all configuration of the repository to happen prior to it being applied? Would it be a bug to attempt to apply configuration to a repository more than once? Overall, I like the direction of this patch so far :) -Justin