From: Patrick Steinhardt <ps@pks.im>
To: Toon Claes <toon@iotcl.com>
Cc: git@vger.kernel.org, Justin Tobler <jltobler@gmail.com>
Subject: Re: [PATCH v2 5/7] environment: split up concerns of `is_bare_repository_cfg`
Date: Fri, 12 Jun 2026 11:28:21 +0200 [thread overview]
Message-ID: <aivRNR-Xss3JTNkc@pks.im> (raw)
In-Reply-To: <87wlw4yys1.fsf@emacs.iotcl.com>
On Fri, Jun 12, 2026 at 09:59:42AM +0200, Toon Claes wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> > diff --git a/setup.c b/setup.c
> > index 71fc6b33da..32f14a8688 100644
> > --- a/setup.c
> > +++ b/setup.c
> > @@ -795,10 +795,22 @@ static int check_repository_format_gently(const char *gitdir,
> > has_common = 0;
> > }
> >
> > - if (!has_common) {
> > - if (candidate->is_bare != -1)
> > - is_bare_repository_cfg = candidate->is_bare;
> > - } else {
> > + if (startup_info->force_bare_repository) {
> > + candidate->is_bare = 1;
> > + FREE_AND_NULL(candidate->work_tree);
> > + } else if (has_common) {
> > + /*
> > + * When sharing a common dir with another repository (e.g. a
> > + * linked worktree), do not let this repository's config
> > + * dictate bareness; it is inherited from the main worktree.
> > + */
> > + candidate->is_bare = -1;
> > +
> > + /*
> > + * Furthermore, "core.worktree" is supposed to be ignored when
> > + * we have a commondir configured, unless it comes from the
> > + * per-worktree configuration.
> > + */
> > FREE_AND_NULL(candidate->work_tree);
> > }
>
> Looking at the diff, this is really hard to understand. But your
> refactor makes sense and the after state is easier to comprehend.
Yeah, I'm in the same boat. Honestly, I really hope that our test suite
has enough coverage so that this refactoring won't cause any significant
regressions. Which isn't exactly a statement of confidence, but rather a
statement of "oh boy, this is awfully complex and has lots of weird edge
cases".
> > @@ -2571,7 +2584,7 @@ static int create_default_files(struct repository *repo,
> > repo_settings_set_shared_repository(repo,
> > init_shared_repository);
> >
> > - is_bare_repository_cfg = !work_tree;
> > + repo->bare_cfg = !work_tree;
>
> I'm curious, do we still need this? If I'm not mistaken, this function
> is called after check_and_apply_repository_format(), which calls
> apply_repository_format() and sets repo->bare_cfg too (see the diff
> above). Or is it explained by what Justin said[1]?
We can't drop this because after we've applied the format we call
`repo_config()` with `git_default_core_config()`, which will potentially
set the `bare_cfg` variable if "core.bare" is set.
Patrick
next prev parent reply other threads:[~2026-06-12 9:28 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 6:56 [PATCH 0/7] setup: drop global state Patrick Steinhardt
2026-06-10 6:56 ` [PATCH 1/7] builtin/init: stop modifying global `git_work_tree_cfg` variable Patrick Steinhardt
2026-06-10 21:15 ` Justin Tobler
2026-06-10 6:56 ` [PATCH 2/7] builtin/init: simplify logic to configure worktree Patrick Steinhardt
2026-06-10 21:29 ` Justin Tobler
2026-06-10 6:56 ` [PATCH 3/7] setup: remove global `git_work_tree_cfg` variable Patrick Steinhardt
2026-06-10 21:52 ` Justin Tobler
2026-06-11 6:36 ` Patrick Steinhardt
2026-06-10 6:56 ` [PATCH 4/7] builtin/init: stop modifying `is_bare_repository_cfg` Patrick Steinhardt
2026-06-10 6:56 ` [PATCH 5/7] environment: split up concerns of `is_bare_repository_cfg` Patrick Steinhardt
2026-06-10 22:22 ` Justin Tobler
2026-06-11 9:19 ` Patrick Steinhardt
2026-06-11 15:33 ` Justin Tobler
2026-06-10 6:56 ` [PATCH 6/7] environment: stop using `the_repository` in `is_bare_repository()` Patrick Steinhardt
2026-06-10 6:56 ` [PATCH 7/7] treewide: drop USE_THE_REPOSITORY_VARIABLE Patrick Steinhardt
2026-06-10 22:26 ` Justin Tobler
2026-06-12 8:02 ` Toon Claes
2026-06-11 6:44 ` [PATCH v2 0/7] setup: drop global state Patrick Steinhardt
2026-06-11 6:44 ` [PATCH v2 1/7] builtin/init: stop modifying global `git_work_tree_cfg` variable Patrick Steinhardt
2026-06-12 8:04 ` Toon Claes
2026-06-12 9:27 ` Patrick Steinhardt
2026-06-11 6:44 ` [PATCH v2 2/7] builtin/init: simplify logic to configure worktree Patrick Steinhardt
2026-06-11 6:44 ` [PATCH v2 3/7] setup: remove global `git_work_tree_cfg` variable Patrick Steinhardt
2026-06-11 6:44 ` [PATCH v2 4/7] builtin/init: stop modifying `is_bare_repository_cfg` Patrick Steinhardt
2026-06-11 6:44 ` [PATCH v2 5/7] environment: split up concerns of `is_bare_repository_cfg` Patrick Steinhardt
2026-06-12 7:59 ` Toon Claes
2026-06-12 9:28 ` Patrick Steinhardt [this message]
2026-06-11 6:44 ` [PATCH v2 6/7] environment: stop using `the_repository` in `is_bare_repository()` Patrick Steinhardt
2026-06-11 6:44 ` [PATCH v2 7/7] treewide: drop USE_THE_REPOSITORY_VARIABLE Patrick Steinhardt
2026-06-11 15:47 ` [PATCH v2 0/7] setup: drop global state Justin Tobler
2026-06-12 8:06 ` Toon Claes
2026-06-12 11:25 ` Patrick Steinhardt
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=aivRNR-Xss3JTNkc@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=jltobler@gmail.com \
--cc=toon@iotcl.com \
/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