Re: [PATCH V2 1/3] wt-status: replace uses of the_repository with local repository instances
- From
Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
- Date
- Feb 5, 2026, 12:18 UTC
- Message-ID
- <20260205121839.38752-1-shreyanshpaliwalcmsmn@gmail.com>
- In-Reply-To
- <CAOLa=ZTFUZF_8YFk=TkMXVYptP6q9_bJRUoBYYsjCMW02NKc7w@mail.gmail.com>
[...]
Show 27 quoted lines
> >> + if (strbuf_read_file(&sb, worktree_git_path(wt->repo, wt, "%s", path), 0) <= 0)
> >> goto got_nothing;
> >>
> >
> > So if you look into `worktree_git_path()`, it has a certain check
> >
> > if (wt && wt->repo != r)
> > BUG("worktree not connected to expected repository");
> >
> > But this is okay with your change, the only question is, do we know wt
> > is always defined here? Unfortunately, wt can be NULL here, in the same
> > file we have:
> >
> > wt_status_check_rebase(NULL, state);
> > -> get_branch(NULL, ...)
> >
> > Which would crash, no? This is applicable for other parts of the code
> > too were we're now using wt->repo.
> >
> > This is also what I was requesting in the previous round, about
> > explaining why it is safe to make a particular change.
> >
> > [snip]
>
> One question, did you run the entire test suite with these changes? I
> would hope that we have tests which would fail if my inference is
> correct. If not, there's a gap in our tests too.You’re right, I hadn’t run the tests initially, as I assumed this was a refactor-only change.
After running the tests, I do see failures, which confirms the issue. I’ll make sure to always run the tests before sending a patch going forward.
Thanks for pointing this out :)