Subject: Re: [PATCH 00/18] setup: drop uses of `the_repository`

From: Junio C Hamano <[email-masked]>
Date: Mon, 20 Apr 2026 10:11:09 -0700

Patrick Steinhardt <[email-masked]> writes:

> Message-Id: <[email-masked]>

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()`

> 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.