Re: [PATCH 10/18] setup: stop using `the_repository` in `set_git_work_tree()`
- From
Elijah Newren <newren@gmail.com>
- Date
- Apr 18, 2026, 01:16 UTC
- Message-ID
- <CABPp-BEe0oN3ZfV6ZhFSADWWj_zEAx0_JUhc=Qc76-aqpSOxTw@mail.gmail.com>
- In-Reply-To
- <20260330-pks-setup-wo-the-repository-v1-10-0d2e822837aa@pks.im>
On Mon, Mar 30, 2026 at 6:19 AM Patrick Steinhardt <ps@pks.im> wrote:
Show 20 quoted lines
> > Stop using `the_repository` in `set_git_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. > > Similar as with the preceding commit, we track whether the worktree has > been initialized already via a global variable so that we can die in > case the repository is re-initialized with a different worktree path. > Store this info in the `struct repository` instead so that we correctly > handle this per repository. > > Signed-off-by: Patrick Steinhardt <ps@pks.im> > --- > builtin/clone.c | 2 +- > builtin/init-db.c | 6 +++--- > repository.h | 1 + > setup.c | 24 +++++++++++------------- > setup.h | 2 +- > 5 files changed, 17 insertions(+), 18 deletions(-) >
> diff --git a/repository.h b/repository.h > index abeef3129e..7ae3d34484 100644 > --- a/repository.h > +++ b/repository.h
[...]
> + bool worktree_initialized; > diff --git a/setup.c b/setup.c
[...]
> > -static int git_work_tree_initialized;
Okay, so we replaced the global git_work_tree_intialized with a repository field named worktree_initialized, _and_ changed its type from int to bool...
> - git_work_tree_initialized = 1; > - repo_set_worktree(the_repository, new_work_tree); > + repo->worktree_initialized = 1; > + repo_set_worktree(repo, new_work_tree);
...yet we still set it to "1". Shouldn't we initialize it to "true" given the typechange?