Re: [PATCH 1/2] wt-status: avoid passing NULL worktree
- From
Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
- Date
- Feb 17, 2026, 10:18 UTC
- Message-ID
- <20260217101950.15731-1-shreyanshpaliwalcmsmn@gmail.com>
- In-Reply-To
- <89c78ce2-1783-416d-9ae5-ef51f6bde58d@gmail.com>
Show 22 quoted lines
> On 16/02/2026 16:18, Phillip Wood wrote:
> >
> > +struct worktree *get_worktree_from_repository(struct repository *repo)
> > +{
> > + struct worktree *wt = xcalloc(1, sizeof(*wt));
> > + char *gitdir = absolute_pathdup(repo->gitdir);
> > + char *commondir = absolute_pathdup(repo->commondir);
> > +
> > + wt->repo = repo;
> > + if (repo->worktree)
> > + wt->path = absolute_pathdup(repo->worktree);
> > + wt->is_bare = !!repo->worktree;
> > + if (fspathcmp(gitdir, commondir))
> > + wt->id = xstrdup(find_last_dir_sep(commondir) + 1);
>
> Oops s/commondir/gitdir/ - I'll wait to see if there are any other
> comments before re-rolling (perhaps with a test that runs git status on
> a rebase in a linked worktree)
>
> Thanks
>
> PhillipI wanted to just check for my understanding: the NULL usage of worktree in get_worktree_git_dir() caller, repo_git_pathv() callers and inside function add_reflogs_to_pending() is intentionally left unchanged for now, and is meant for a follow-up once this gets gets finalized. or it is out of scope wrt this cleanup?
Best, Shreyansh