From: Toon Claes <toon@iotcl.com>
To: Patrick Steinhardt <ps@pks.im>, git@vger.kernel.org
Cc: Justin Tobler <jltobler@gmail.com>, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v2 05/13] setup: introduce explicit repository discovery
Date: Wed, 08 Jul 2026 11:32:40 +0200 [thread overview]
Message-ID: <87ldblomh3.fsf@emacs.iotcl.com> (raw)
In-Reply-To: <20260707-pks-setup-split-discovery-and-setup-v2-5-aab372cd227c@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
> 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.
>
> 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.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> setup.c | 155 ++++++++++++++++++++++++++++++++++++++++------------------------
> 1 file changed, 98 insertions(+), 57 deletions(-)
>
> diff --git a/setup.c b/setup.c
> index 324a235dd1..f713d024f7 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -1090,14 +1090,47 @@ static void apply_and_export_relative_gitdir(struct repository *repo, const char
> strbuf_release(&realpath);
> }
>
> -static const char *setup_explicit_git_dir(struct repository *repo,
> - const char *gitdirenv,
> - struct strbuf *cwd,
> - struct repository_format *repo_fmt,
> - int *nongit_ok)
> +struct repo_discovery {
> + char *gitdir;
> + char *worktree;
> +};
I like where you're going with this. It's nicer to have a struct that
captures what we know and has accurate data, instead of having a
`repository` that's only partly initialized.
--
Cheers,
Toon
next prev parent reply other threads:[~2026-07-08 9:33 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 11:47 [PATCH 00/13] setup: split up repository discovery and setup Patrick Steinhardt
2026-06-30 11:47 ` [PATCH 01/13] setup: rename `check_repository_format_gently()` Patrick Steinhardt
2026-07-06 21:27 ` Justin Tobler
2026-06-30 11:47 ` [PATCH 02/13] setup: mark bogus worktree in `apply_repository_format()` Patrick Steinhardt
2026-06-30 18:26 ` Junio C Hamano
2026-07-01 6:23 ` Patrick Steinhardt
2026-07-06 21:49 ` Justin Tobler
2026-07-07 6:25 ` Patrick Steinhardt
2026-06-30 11:47 ` [PATCH 03/13] setup: unify setup of shallow file Patrick Steinhardt
2026-07-06 22:02 ` Justin Tobler
2026-07-07 6:25 ` Patrick Steinhardt
2026-06-30 11:47 ` [PATCH 04/13] setup: split up concerns of `setup_git_env_internal()` Patrick Steinhardt
2026-06-30 11:47 ` [PATCH 05/13] setup: introduce explicit repository discovery Patrick Steinhardt
2026-07-06 22:19 ` Justin Tobler
2026-07-07 6:25 ` Patrick Steinhardt
2026-06-30 11:47 ` [PATCH 06/13] setup: embed repository format in discovery Patrick Steinhardt
2026-06-30 11:47 ` [PATCH 07/13] setup: move prefix into repository Patrick Steinhardt
2026-07-06 22:33 ` Justin Tobler
2026-06-30 11:47 ` [PATCH 08/13] setup: drop static `cwd` variable Patrick Steinhardt
2026-06-30 11:47 ` [PATCH 09/13] setup: propagate prefix via repository discovery Patrick Steinhardt
2026-06-30 11:47 ` [PATCH 10/13] setup: make repository discovery self-contained Patrick Steinhardt
2026-06-30 11:47 ` [PATCH 11/13] setup: drop redundant configuration of `startup_info->have_repository` Patrick Steinhardt
2026-06-30 11:47 ` [PATCH 12/13] setup: pass worktree to `init_db()` Patrick Steinhardt
2026-06-30 11:47 ` [PATCH 13/13] setup: mark `set_git_work_tree()` as file-local Patrick Steinhardt
2026-07-07 7:21 ` [PATCH v2 00/13] setup: split up repository discovery and setup Patrick Steinhardt
2026-07-07 7:21 ` [PATCH v2 01/13] setup: rename `check_repository_format_gently()` Patrick Steinhardt
2026-07-07 7:21 ` [PATCH v2 02/13] setup: mark bogus worktree in `apply_repository_format()` Patrick Steinhardt
2026-07-07 7:21 ` [PATCH v2 03/13] setup: unify setup of shallow file Patrick Steinhardt
2026-07-07 7:21 ` [PATCH v2 04/13] setup: split up concerns of `setup_git_env_internal()` Patrick Steinhardt
2026-07-07 7:21 ` [PATCH v2 05/13] setup: introduce explicit repository discovery Patrick Steinhardt
2026-07-08 9:32 ` Toon Claes [this message]
2026-07-07 7:21 ` [PATCH v2 06/13] setup: embed repository format in discovery Patrick Steinhardt
2026-07-07 7:21 ` [PATCH v2 07/13] setup: move prefix into repository Patrick Steinhardt
2026-07-07 7:21 ` [PATCH v2 08/13] setup: drop static `cwd` variable Patrick Steinhardt
2026-07-07 7:21 ` [PATCH v2 09/13] setup: propagate prefix via repository discovery Patrick Steinhardt
2026-07-07 7:21 ` [PATCH v2 10/13] setup: make repository discovery self-contained Patrick Steinhardt
2026-07-07 7:21 ` [PATCH v2 11/13] setup: drop redundant configuration of `startup_info->have_repository` Patrick Steinhardt
2026-07-07 7:21 ` [PATCH v2 12/13] setup: pass worktree to `init_db()` Patrick Steinhardt
2026-07-07 7:21 ` [PATCH v2 13/13] setup: mark `set_git_work_tree()` as file-local Patrick Steinhardt
2026-07-07 15:02 ` [PATCH v2 00/13] setup: split up repository discovery and setup Justin Tobler
2026-07-07 17:58 ` Junio C Hamano
2026-07-08 9:42 ` Toon Claes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ldblomh3.fsf@emacs.iotcl.com \
--to=toon@iotcl.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jltobler@gmail.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox