public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail•com>
To: git@vger•kernel.org
Cc: gitster@pobox•com, karthik.188@gmail•com, phillip.wood123@gmail•com
Subject: Re: [PATCH V2 2/3] wt-status: pass struct repository and wt_status through function parameters
Date: Fri,  6 Feb 2026 22:36:54 +0530	[thread overview]
Message-ID: <20260206170747.1231093-1-shreyanshpaliwalcmsmn@gmail.com> (raw)
In-Reply-To: <997a4a47-2d00-418f-b0a6-3e4dc2f45bbb@gmail.com>

> On 06/02/2026 12:57, Shreyansh Paliwal wrote:
> > I tried this out below, and it showed no fails in tests.
> > After this we can just directly replace all the_repository with 'r' or 's->repo'
> > without the hassle of checking the worktree is defined or not.
> 
> As we're trying to remove uses of "the_repository" I think you should 
> use "wt->repo" where we know always "wt != NULL". There are not many 
> callers of these functions so is easy to do necessary analysis (see below).
> 
> > diff --git a/branch.c b/branch.c
> > index 243db7d0fc..0a0097dd85 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(the_repository, wt, &state) &&
> 
> As I said yesterday we know "wt != NULL" here so it is fine to use 
> "wt->repo" rather than introduce a new use of "the_repository", you just 
> need to explain that in the commit message.
> 
> >   		    (state.rebase_in_progress || state.rebase_interactive_in_progress) &&
> >   		    state.branch) {
> >   			struct strbuf ref = STRBUF_INIT;
> > @@ -425,7 +425,7 @@ static void prepare_checked_out_branches(void)
> >   		}
> >   		wt_status_state_free_buffers(&state);
> >   
> > -		if (wt_status_check_bisect(wt, &state) &&
> > +		if (wt_status_check_bisect(the_repository, wt, &state) &&
> 
> The same is true here.
> 
> >   		    state.bisecting_from) {
> >   			struct strbuf ref = STRBUF_INIT;
> >   			strbuf_addf(&ref, "refs/heads/%s", state.bisecting_from);
> > diff --git a/worktree.c b/worktree.c
> > index 9308389cb6..86eff384ae 100644
> > --- a/worktree.c
> > +++ b/worktree.c
> > @@ -443,7 +443,7 @@ int is_worktree_being_rebased(const struct worktree *wt,
> >   	int found_rebase;
> >   
> >   	memset(&state, 0, sizeof(state));
> > -	found_rebase = wt_status_check_rebase(wt, &state) &&
> > +	found_rebase = wt_status_check_rebase(the_repository, wt, &state) &&
> 
> This function is called from 
> builtin/branch.c:reject_rebase_or_bisect_branch() with "wt != NULL". It 
> is also called from worktree.c:is_shared_symref() which dereferences wt 
> before calling this function so we can assume "wt != NULL" there as 
> well. That means we can use "wt->repo" here.
> 
> >   		       (state.rebase_in_progress ||
> >   			state.rebase_interactive_in_progress) &&
> >   		       state.branch &&
> > @@ -460,7 +460,7 @@ int is_worktree_being_bisected(const struct worktree *wt,
> >   	int found_bisect;
> >   
> >   	memset(&state, 0, sizeof(state));
> > -	found_bisect = wt_status_check_bisect(wt, &state) &&
> > +	found_bisect = wt_status_check_bisect(the_repository, wt, &state) &&
> 
> The same analysis for is_worktree_being_rebased() applies here.
> 
> The changes to get_branch() below look sensible

Thank you for explaining this and for each case.
I have understood where wt->repo can be used safely.
Will make changes and send a v3.
Hopefully that will be good to go :)

Best,
Shreyansh

  reply	other threads:[~2026-02-06 17:08 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-31 18:57 [PATCH 0/3] wt-status: reduce reliance on global state Shreyansh Paliwal
2026-01-31 18:57 ` [PATCH 1/3] wt-status: replace uses of the_repository with local repository instances Shreyansh Paliwal
2026-02-02 10:02   ` Karthik Nayak
2026-02-02 18:42     ` Junio C Hamano
2026-02-02 18:57     ` Shreyansh Paliwal
2026-02-02 22:41       ` Junio C Hamano
2026-02-02 23:03         ` Junio C Hamano
2026-02-03  9:53           ` Shreyansh Paliwal
2026-02-03 11:06             ` Phillip Wood
2026-02-03 15:20               ` Shreyansh Paliwal
2026-02-03 10:58       ` Phillip Wood
2026-02-03 15:15         ` Shreyansh Paliwal
2026-01-31 18:57 ` [PATCH 2/3] wt-status: pass struct repository and wt_status through function parameters Shreyansh Paliwal
2026-01-31 18:57 ` [PATCH 3/3] wt-status: use hash_algo from local repository instead of global the_hash_algo Shreyansh Paliwal
2026-02-02 10:03   ` Karthik Nayak
2026-02-02 19:03     ` Shreyansh Paliwal
2026-02-04 10:18       ` Karthik Nayak
2026-02-04 11:22         ` Shreyansh Paliwal
2026-02-05 10:13 ` [PATCH V2 0/3] wt-status: reduce reliance on global state Shreyansh Paliwal
2026-02-05 10:13   ` [PATCH V2 1/3] wt-status: replace uses of the_repository with local repository instances Shreyansh Paliwal
2026-02-05 10:59     ` Karthik Nayak
2026-02-05 11:11       ` Karthik Nayak
2026-02-05 12:18         ` Shreyansh Paliwal
2026-02-05 16:08           ` Phillip Wood
2026-02-05 17:41             ` Shreyansh Paliwal
2026-02-05 10:13   ` [PATCH V2 2/3] wt-status: pass struct repository and wt_status through function parameters Shreyansh Paliwal
2026-02-05 11:09     ` Karthik Nayak
2026-02-05 12:04       ` Shreyansh Paliwal
2026-02-06  9:24         ` Karthik Nayak
2026-02-06  9:32           ` Shreyansh Paliwal
2026-02-06 12:57             ` Shreyansh Paliwal
2026-02-06 14:54               ` Phillip Wood
2026-02-06 17:06                 ` Shreyansh Paliwal [this message]
2026-02-05 15:58       ` Phillip Wood
2026-02-05 10:13   ` [PATCH V2 3/3] wt-status: use hash_algo from local repository instead of global the_hash_algo Shreyansh Paliwal
2026-02-05 10:27   ` [PATCH V2 0/3] wt-status: reduce reliance on global state Shreyansh Paliwal
2026-02-05 15:53     ` Phillip Wood
2026-02-05 17:39       ` Shreyansh Paliwal
2026-02-05 18:02         ` Kristoffer Haugsbakk
2026-02-05 18:18           ` Shreyansh Paliwal
2026-02-07 10:00   ` [PATCH v3 " Shreyansh Paliwal
2026-02-07 10:00     ` [PATCH v3 1/3] wt-status: pass struct repository through function parameters Shreyansh Paliwal
2026-02-08  1:14       ` Junio C Hamano
2026-02-08  4:55         ` [PATCH V2 2/3] wt-status: pass struct repository and wt_status " Shreyansh Paliwal
2026-02-09  8:36         ` [PATCH v3 1/3] wt-status: pass struct repository " Karthik Nayak
2026-02-08  1:21       ` Junio C Hamano
2026-02-08  4:44         ` [PATCH V2 2/3] wt-status: pass struct repository and wt_status " Shreyansh Paliwal
2026-02-08  6:08           ` Junio C Hamano
2026-02-08 15:25             ` Shreyansh Paliwal
2026-02-09  9:02               ` Karthik Nayak
2026-02-09 13:43                 ` Shreyansh Paliwal
2026-02-09 16:13                 ` Junio C Hamano
2026-02-10  9:50                   ` Karthik Nayak
2026-02-07 10:00     ` [PATCH v3 2/3] wt-status: replace uses of the_repository with local repository instances Shreyansh Paliwal
2026-02-07 10:00     ` [PATCH v3 3/3] wt-status: use hash_algo from local repository instead of global the_hash_algo Shreyansh Paliwal
2026-02-17 17:29 ` [PATCH v4 0/3] wt-status: reduce reliance on global state Shreyansh Paliwal
2026-02-17 17:29   ` [PATCH v4 1/3] wt-status: pass struct repository through function parameters Shreyansh Paliwal
2026-02-17 17:29   ` [PATCH v4 2/3] wt-status: replace uses of the_repository with local repository instances Shreyansh Paliwal
2026-02-17 17:29   ` [PATCH v4 3/3] wt-status: use hash_algo from local repository instead of global the_hash_algo Shreyansh Paliwal
2026-02-18 16:13   ` [PATCH v4 0/3] wt-status: reduce reliance on global state Phillip Wood
2026-02-18 16:48     ` Shreyansh Paliwal
2026-02-18 17:53 ` [PATCH v5 " Shreyansh Paliwal
2026-02-18 17:53   ` [PATCH v5 1/3] wt-status: pass struct repository through function parameters Shreyansh Paliwal
2026-02-18 17:53   ` [PATCH v5 2/3] wt-status: replace uses of the_repository with local repository instances Shreyansh Paliwal
2026-02-18 17:53   ` [PATCH v5 3/3] wt-status: use hash_algo from local repository instead of global the_hash_algo Shreyansh Paliwal
2026-03-06 22:31   ` [PATCH v5 0/3] wt-status: reduce reliance on global state Junio C Hamano
2026-03-09 10:32     ` Karthik Nayak
2026-03-09 18:30       ` Junio C Hamano
2026-03-09 10:35     ` Phillip Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260206170747.1231093-1-shreyanshpaliwalcmsmn@gmail.com \
    --to=shreyanshpaliwalcmsmn@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=karthik.188@gmail$(echo .)com \
    --cc=phillip.wood123@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox