Re: [PATCH v3 1/3] wt-status: pass struct repository through function parameters
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Feb 9, 2026, 08:36 UTC
- Message-ID
- <CAOLa=ZQB3C9mr1z7QdxzFp34d0uV71ho6nRxgYLgpRV6sNkBYg@mail.gmail.com>
- In-Reply-To
- <xmqqzf5k9guh.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 29 quoted lines
> Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com> writes: > >> branch.c | 4 ++-- >> worktree.c | 4 ++-- >> wt-status.c | 48 +++++++++++++++++++++++++----------------------- >> wt-status.h | 6 ++++-- >> 4 files changed, 33 insertions(+), 29 deletions(-) >> >> diff --git a/branch.c b/branch.c >> index 243db7d0fc..e3cf273339 100644 >> --- a/branch.c >> +++ b/branch.c >> @@ -412,7 +412,7 @@ static void prepare_checked_out_branches(void) >> free(old); >> } >> >> - if (wt_status_check_rebase(wt, &state) && >> + if (wt_status_check_rebase(wt->repo, wt, &state) && > > I am not sure if this is an improvement for callers of the API. > > Isn't wt_anything() that takes a worktree "wt" supposed to work with > the wt->repo repository? Or is the API designed to be used to take > any repository object that is _different_ from wt->repo? I am > assuming it is the former, and if so, the only effect of adding a > repository parameter to a function that already takes struct > worktree is to invite a programming error to pass a repository that > the wt is not designed to work with, isn't it? >
Absolutely, In a previous version, the patched directly used `wt->repo`. I pointed out that there are instances where `wt` could be NULL as per the existing flow. So this change is in accordance with that. Overall I think the fix should ideally be around how we work with worktrees.
>> - if (wt_status_check_bisect(wt, &state) && >> + if (wt_status_check_bisect(wt->repo, wt, &state) && > > Ditto.