mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <>
To: "Rubén Justo" <>
Cc: Git List <>,
	Phillip Wood <>
Subject: Re: [PATCH v2] bisect: fix "reset" when branch is checked out elsewhere
Date: Mon, 06 Feb 2023 14:29:03 -0800	[thread overview]
Message-ID: <xmqqwn4u2ztc.fsf@gitster.g> (raw)
In-Reply-To: <> ("Rubén Justo"'s message of "Sat, 4 Feb 2023 23:57:14 +0100")

Rubén Justo <> writes:

> Since 1d0fa89 (checkout: add --ignore-other-wortrees, 2015-01-03) we
> have a safety valve in checkout/switch to prevent the same branch from
> being checked out simultaneously in multiple worktrees.
> If a branch is bisected in a worktree while also being checked out in
> another worktree; when the bisection is finished, checking out the
> branch back in the current worktree may fail.

Sorry for asking possibly the same question again (which may mean
that the phrasing of this paragraph is misleading), but isn't it a
good thing if in this sequence:

 - I checkout 'main' and start bisecting (BISECT_HEAD says 'main');

 - I then checkout 'main' in another worktree; I may even make a
   commit or two, or even rename 'main' to 'master'.

 - I finish bisection and "bisect reset" tries to take me back to
   'main', which may notice that 'main' is checked out in the other
   worktree, and fail.

the last one failed?  After the above sequence, I now have two
worktrees, both checking out 'main', and it is exactly the situation
the safety valve tries to prevent from occuring, no?

Or is the new behaviour considered better because the third step
would try to check out 'main' that is checked out elsewhere only if
the second step was forced, so the person who decided to touch
'main' in another worktree should already be aware of the risk and
we should disable the safety valve in the third step automatically?

I am not sure if that is a sensible argument, but if that is the
case, let's spell it out in the proposed log message.


>  builtin/bisect.c            |  5 ++++-
>  t/ | 23 +++++++++++++++++++++++
>  2 files changed, 27 insertions(+), 1 deletion(-)
> diff --git a/builtin/bisect.c b/builtin/bisect.c
> index 7301740267..46fba8db50 100644
> --- a/builtin/bisect.c
> +++ b/builtin/bisect.c
> @@ -244,7 +244,10 @@ static int bisect_reset(const char *commit)
>  		struct child_process cmd = CHILD_PROCESS_INIT;
>  		cmd.git_cmd = 1;
> -		strvec_pushl(&cmd.args, "checkout", branch.buf, "--", NULL);
> +		strvec_pushl(&cmd.args, "checkout", NULL);
> +		if (!commit)
> +			strvec_pushl(&cmd.args, "--ignore-other-worktrees", NULL);
> +		strvec_pushl(&cmd.args, branch.buf, "--", NULL);

OK, so this time around "git bisect reset" to go back to the
original branch gets --ignore-other-worktrees but "git bisect reset
HEAD" or other forms that names a branch still gets the safety.
That makes the blast radius smaller, but I am not 100% sure if
loosening the safety is a good thing.

  reply	other threads:[~2023-02-06 22:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-22  1:38 [PATCH] bisect: fix "reset" when branch is checked out elsewhere Rubén Justo
2023-01-23  2:01 ` Junio C Hamano
2023-01-26  2:18   ` Rubén Justo
2023-01-26 17:06     ` Junio C Hamano
2023-01-26 17:13       ` Junio C Hamano
2023-02-04 22:46       ` Rubén Justo
2023-02-06 19:04         ` Junio C Hamano
2023-02-04 22:57 ` [PATCH v2] " Rubén Justo
2023-02-06 22:29   ` Junio C Hamano [this message]
2023-02-08  0:30     ` Rubén Justo
2023-02-08  5:16       ` Junio C Hamano
2023-02-08 21:54         ` Rubén Justo
2023-02-15  4:52   ` Eric Sunshine
2023-02-15 22:20     ` Rubén Justo
2023-02-20 22:53   ` [PATCH v3] " Rubén Justo

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:

  List information:

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

  git send-email \
    --in-reply-to=xmqqwn4u2ztc.fsf@gitster.g \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).