git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 26, 2023, 17:06 UTC
Message-ID
<xmqqzga5b4yz.fsf@gitster.g>
In-Reply-To
<0d04f8ed-6933-9354-1f64-24d827424c71@gmail.com>
Rubén Justo <rjusto@gmail.com> writes:
Show 14 quoted lines
> But, and this is what makes me think that "checking out will fail" is the wrong
> choice for "bisect", while bisecting, with the worktree in a detached HEAD
> state, the branch to which "bisect reset" will check out back (BISECT_START),
> is still considered checked out in the working tree:
>
> 	$ git checkout -b work
> 	$ git bisect start HEAD HEAD~3
> 	... bisect detaches the current worktree ...
> 	$ git worktree add work
> 	Preparing worktree (checkout out 'work')
> 	fatal: 'work' is already checked out at ...
>
> So, checking out back to the implicitly checked out branch sounds like it
> should not fail.

If that is what you are aiming at, I suspect that the posted patch is doing it in a wrong way. Instead, we should just declare that the branch being bisected does not mean the branch cannot be checked out elsewhere, so that

	$ git worktree add --detach ../another HEAD^0
	$ git checkout -b work
	$ git bisect start work work~3
        ... detaches ...
	$ git -C ../another checkout work
should just work, no?

I admit I haven't thought things through, but I tend to be sympathetic to such a declaration. After all, "bisect" is a read-only operation as far as the branch you happened to be on when you started a bisect session is concerned. Jumping around and materializing tree states recorded in various commits leading to the tip of the branch and inspecting them would not change anything on the branch itself. And more importantly, the branch being checked out in another worktree and modified there should not break the bisection, EXCEPT that the final "git bisect reset" (without arguments) would fail if the other worktree removed the branch.

So, how about removing the is_worktree_being_bisected() check from find_shared_symref(), so that not just "worktree add" and "bisect reset", but "checkout" and "switch" are allowed to make the branch current even it is being bisected elsewhere?

That would affect the other topic, I suspect, as well. It may be a positive change. Or are there cases I missed, where the branch being bisected should not be touched from elsewhere, and we cannot remove the check from find_shared_symref()?

Thanks.
Previous: Rubén JustoNext: Junio C Hamano
Message 4 of 15 in “bisect: fix "reset" when branch is checked out elsewhere”
  1. bisect: fix "reset" when branch is checked out elsewhereRubén Justo, Jan 22, 2023
  2. Junio C HamanoJan 23, 2023
  3. Rubén JustoJan 26, 2023
  4. Junio C HamanoJan 26, 2023
  5. Junio C HamanoJan 26, 2023
  6. Rubén JustoFeb 4, 2023
  7. Junio C HamanoFeb 6, 2023
  8. bisect: fix "reset" when branch is checked out elsewhereRubén Justo, Feb 4, 2023
  9. Junio C HamanoFeb 6, 2023
  10. Rubén JustoFeb 8, 2023
  11. Junio C HamanoFeb 8, 2023
  12. Rubén JustoFeb 8, 2023
  13. Eric SunshineFeb 15, 2023
  14. Rubén JustoFeb 15, 2023
  15. bisect: fix "reset" when branch is checked out elsewhereRubén Justo, Feb 20, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.