Subject: Re: [PATCH V2 1/3] wt-status: replace uses of the_repository with local repository instances

From: Shreyansh Paliwal <[email-masked]>
Date: Thu, 5 Feb 2026 17:48:27 +0530

[...]
> >> +	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 :)