From: Patrick Steinhardt <ps@pks.im>
To: Elijah Newren <newren@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 09/18] setup: stop using `the_repository` in `setup_work_tree()`
Date: Mon, 20 Apr 2026 09:06:24 +0200 [thread overview]
Message-ID: <aeXQcDF-wHT4wEG-@pks.im> (raw)
In-Reply-To: <CABPp-BHOvDaWXXDnpPsoDTe-En7T4LUaVqcJZ5Jst8zaQ-mrTg@mail.gmail.com>
On Fri, Apr 17, 2026 at 06:11:48PM -0700, Elijah Newren wrote:
> On Mon, Mar 30, 2026 at 6:30 AM Patrick Steinhardt <ps@pks.im> wrote:
> >
> > Stop using `the_repository` in `setup_work_tree()` and instead accept
> > the repository as a parameter. The injection of `the_repository` is thus
> > bumped one level higher, where callers now pass it in explicitly.
> >
> > Note that the function tracks bogus worktree configuration via a global
> > variable. If we have bogus configuration, and if later on some caller
> > tries to setup a worktree, then we'll die instead.
> >
> > Of course, tracking this as a global variable doesn't make sense anymore
> > now that we can set up worktrees for arbitrary repositories. Move the
> > variable into `struct repository` instead.
>
> Okay, we don't want a global, makes sense.
>
> > Signed-off-by: Patrick Steinhardt <ps@pks.im>
>
> > diff --git a/setup.c b/setup.c
> > index dca32addae..64a030c6cd 100644
> > --- a/setup.c
> > +++ b/setup.c
> > @@ -26,7 +26,6 @@
> > #include "trace2.h"
> > #include "worktree.h"
> >
> > -static int work_tree_config_is_bogus;
>
> So, we removed this global....
>
> > enum allowed_bare_repo {
> > ALLOWED_BARE_REPO_EXPLICIT = 0,
> > ALLOWED_BARE_REPO_ALL,
> > @@ -485,7 +484,7 @@ int is_inside_work_tree(struct repository *repo)
> > return is_inside_dir(strbuf_realpath(&buf, worktree, 1));
> > }
> >
> > -void setup_work_tree(void)
> > +void setup_work_tree(struct repository *repo)
> > {
> > const char *work_tree;
> > static int initialized = 0;
>
> ...but we left this one...
>
> > @@ -493,10 +492,10 @@ void setup_work_tree(void)
> > if (initialized)
> > return;
>
> ...and because of this other global, we still can only set up one work
> tree in the process anyway. Should 'initialized' also be moved to a
> field within repo?
Good catch. I thought I fixed this instance in a later commit or in the
next patch series, but I seemingly don't. Will adapt, thanks!
Patrick
next prev parent reply other threads:[~2026-04-20 7:06 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-30 13:17 [PATCH 00/18] setup: drop uses of `the_repository` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 01/18] setup: replace use of `the_repository` in static functions Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 02/18] setup: stop using `the_repository` in `is_inside_worktree()` Patrick Steinhardt
2026-04-09 11:55 ` Karthik Nayak
2026-03-30 13:17 ` [PATCH 03/18] setup: stop using `the_repository` in `is_inside_git_dir()` Patrick Steinhardt
2026-04-09 12:58 ` Karthik Nayak
2026-04-13 5:47 ` Patrick Steinhardt
2026-04-13 15:36 ` Junio C Hamano
2026-03-30 13:17 ` [PATCH 04/18] setup: stop using `the_repository` in `prefix_path()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 05/18] setup: stop using `the_repository` in `path_inside_repo()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 06/18] setup: stop using `the_repository` in `verify_filename()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 07/18] setup: stop using `the_repository` in `verify_non_filename()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 08/18] setup: stop using `the_repository` in `enter_repo()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 09/18] setup: stop using `the_repository` in `setup_work_tree()` Patrick Steinhardt
2026-04-18 1:11 ` Elijah Newren
2026-04-20 7:06 ` Patrick Steinhardt [this message]
2026-03-30 13:17 ` [PATCH 10/18] setup: stop using `the_repository` in `set_git_work_tree()` Patrick Steinhardt
2026-04-18 1:16 ` Elijah Newren
2026-04-20 7:06 ` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 11/18] setup: stop using `the_repository` in `setup_git_env()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 12/18] setup: stop using `the_repository` in `setup_git_directory_gently()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 13/18] setup: stop using `the_repository` in `setup_git_directory()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 14/18] setup: stop using `the_repository` in `upgrade_repository_format()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 15/18] setup: stop using `the_repository` in `check_repository_format()` Patrick Steinhardt
2026-04-18 1:23 ` Elijah Newren
2026-04-20 7:06 ` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 16/18] setup: stop using `the_repository` in `initialize_repository_version()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 17/18] setup: stop using `the_repository` in `create_reference_database()` Patrick Steinhardt
2026-03-30 13:17 ` [PATCH 18/18] setup: stop using `the_repository` in `init_db()` Patrick Steinhardt
2026-04-09 13:05 ` [PATCH 00/18] setup: drop uses of `the_repository` Karthik Nayak
2026-04-13 5:48 ` Patrick Steinhardt
-- strict thread matches above, loose matches on Subject: below --
2026-04-20 8:22 Patrick Steinhardt
2026-04-20 8:22 ` [PATCH 09/18] setup: stop using `the_repository` in `setup_work_tree()` 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=aeXQcDF-wHT4wEG-@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=newren@gmail.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