Re: [PATCH 00/18] setup: drop uses of `the_repository`
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 20, 2026, 17:11 UTC
- Message-ID
- <xmqqy0ihpnf6.fsf@gitster.g>
- In-Reply-To
- <20260420-pks-setup-wo-the-repository-v1-0-f4a81c4988e8@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
> Message-Id: <20260420-pks-setup-wo-the-repository-v1-0-f4a81c4988e8@pks.im>
There seem to be some tool errors that made this marked as v1 (hence no References/In-Reply-To).
> - 9/18: setup: stop using `the_repository` in `setup_work_tree()`
Show 9 quoted lines
> diff --git a/setup.c b/setup.c > index dca32addae..80dd94b261 100644 > --- a/setup.c > +++ b/setup.c > @@ -26,7 +26,6 @@ > #include "trace2.h" > #include "worktree.h" > > -static int work_tree_config_is_bogus;
Once we start "setting up" more than one instance of "struct repository", "the worktree configuration given to us is bogus" bit cannot be a singleton global that applies across repositories.
Hopefully nobody sets core.bare and core.worktree in configuration files other than the repository local one. Otherwise a lot of interesting would break ;-)
I am not quite sure the reasoning behind removing "initialized" global without any replacement was properly explained, with "should ultimately be idempotent". This can give us a huge performance regression, if the callers have been relying on setup_work_tree() to be _cheap_ when they call it "just in case" no other potential callsites have called it, even though all of them know that the current code works only with the_repository (in other words, they call because the switched into the_repository---they do not know for sure if other call sites have called it).
Or does the current code never call setup_work_tree() twice, because everybody knows that we never work with anything other than the_repository?
Other than that, the [09/18] step looks sensible to me.
Thanks.