Re: [PATCH V2 2/3] wt-status: pass struct repository and wt_status through function parameters
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Feb 5, 2026, 15:58 UTC
- Message-ID
- <f432e771-8247-4305-afef-94333729033d@gmail.com>
- In-Reply-To
- <CAOLa=ZSkTH8KC04KubktP1EkU4EHYs0CtmUPkPVe74zi0wcTBA@mail.gmail.com>
On 05/02/2026 11:09, Karthik Nayak wrote:
Show 9 quoted lines
> Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com> writes: > >> Some functions in wt-status.c relied on the_repository because no >> repository instance was available in their local scope. >> There is also a specific case in wt_status_check_rebase() where the >> worktree can be NULL, so accessing wt->repo may lead to a segfault. >> >> Update these functions to accept a struct repository or struct >> wt_status parameter, and adjust callers accordingly.
These callers pass wt->repo so it's important to explain that the callers all have a non-NULL worktree instance so passing wt->repo to wt_status_check_rebase() is safe.
Show 11 quoted lines
>> Replace the >> remaining uses of the_repository in these functions with the >> passed-in repository instance. >> >> This removes the use of the_repository global variable from >> wt-status.c completely. >> > > Okay, but this doesn't fix the issue I stated in the previous commit. I > do wonder if we can re-order the commits and pass the repo struct to > functions like 'get_branch()'.
That sounds like a good suggestion
Thanks
Phillip