Subject: Re: [PATCH v2] bisect: fix "reset" when branch is checked out elsewhere

From: Junio C Hamano <[email-masked]>
Date: Tue, 07 Feb 2023 21:16:59 -0800

Rubén Justo <[email-masked]> writes:

> No problem.  I am sorry because I don't understand what's worrying you.
>
>> 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?
>
> We are considering the initial branch (BISECT_START) as a branch checked
> out _implicitly_ in the worktree that is bisecting.  Doesn't that
> provide us and the user enough safety?

If that is a question, then the answer is no.  If that is
rhetorical, then I just do not see how it gives us any safety.

In the end, if you allow "bisect reset" to check out 'main' in the
worktree you used to run bisection, the 'main' branch is checked out
twice, once there, and another checkout in the other worktree.  That
is exactly what "git checkout 'main'" in one worktree while 'main'
is already checked out in another would prevent from happening, no?