Re: [PATCH 1/3] wt-status: replace uses of the_repository with local repository instances
- From
Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
- Date
- Feb 3, 2026, 15:15 UTC
- Message-ID
- <20260203151613.36957-1-shreyanshpaliwalcmsmn@gmail.com>
- In-Reply-To
- <50791aed-c64b-48fe-8cc7-8cacaec9d295@gmail.com>
Show 16 quoted lines
> > The replacement of all the_repository with s->repo in this patch are mostly > > to cases where a repository instance is already available via struct wt_status. > > > > In the current flow, all functions operating on struct wt_status *s > > are called via commit.c. There, status_init_config() calls > > wt_status_prepare(), which initializes the struct wt_status and > > assigns s->repo from the repository instance passed in by the caller. > > As a result, s->repo is guaranteed to be initialized whenever these > > functions are invoked. > > > > And commit.c itself still relies on the_repository, within wt-status.c, > > the local repository pointer refers to the same underlying > > repository object that the_repository would have pointed to, indirectly > > until we make commit.c also free of the_repository. > > Good explanation, that would be a very useful addition to the commit message
Sure I will include this in v2.
Show 22 quoted lines
> >>> @@ -1723,18 +1723,18 @@ int wt_status_check_rebase(const struct worktree *wt,
> >>> {
> >>> struct stat st;
> >>>
> >>> - if (!stat(worktree_git_path(the_repository, wt, "rebase-apply"), &st)) {
> >>> - if (!stat(worktree_git_path(the_repository, wt, "rebase-apply/applying"), &st)) {
> >>> + if (!stat(worktree_git_path(wt->repo, wt, "rebase-apply"), &st)) {
> >>> + if (!stat(worktree_git_path(wt->repo, wt, "rebase-apply/applying"), &st)) {
> >>
> >> In the same file we make a call 'wt_status_check_rebase(NULL, state)',
> >> so wouldn't this break?
> >
> > Yes my bad, it would throw a segfault error.
> > I think the best way to handle this is to explicitly check for the
> > wt to be valid like this,
> >
> > if (wt==NULL)
> > return 0;
>
> That would change the behavior of the function though as it will no
> longer check if the rebase directories exist. You should pass the
> repository down from the caller.Yes agreed. I will pass s->repo as struct repository *r in this function. Thanks.
Best, Shreyansh