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

[BUG] git bisect start gives incorrect error message when good/bad swapped

From
Britton Kerin <britton.kerin@gmail.com>
Date
Dec 11, 2023, 06:20 UTC
Message-ID
<CAC4O8c-KmafnX2z_6JK5YxjWcegykwZvk9xx2OuYdLLR5gVk_g@mail.gmail.com>
When good/bad are entirely swapped git bisect says:
     $ git bisect start initial_commit latest_master_commit
     Some good revs are not ancestors of the bad rev.
     git bisect cannot work properly in this case.
     Maybe you mistook good and bad revs?

But that's not true because when good is a non-ancestor from a branch a common ancestor is automatically selected:

     $ git bisect start latest_master_commit latest_unmerged_branch_commit
     Bisecting: a merge base must be tested
     [b93212577c2e8603ed7285b55a0931dcf552c628] I'm yet another test commit

In this case latest_unmerged_branch_commit is not an ancestor of latest_master_commit but a common ancestor is selected automatically with a message, and when the branch point is marked as bad git correctly indicates that the problem has been fixed on the branch (and bisection stops):

     $ git bisect bad
     The merge base b93212577c2e8603ed7285b55a0931dcf552c628 is bad.
     This means the bug has been fixed between
b93212577c2e8603ed7285b55a0931dcf552c628 and
[1b4470e66cb26244be9aa5f68cca042a0ef4270e].

I suspect what the message at the top should be saying is that the bad rev *is* an ancestor of some good rev but I haven't thought/tested carefully enough to feel sure that's the case.

I think this is worth fixing somehow because the wrong message gives a wrong idea of git capabilities and might make the case when a common ancestor is automatically selected more unexpected and so more confusing.

On a more minor note the use of 'merge base' to refer to the common ancestor is unfortunate since these messages are produced when working on branches that aren't actually merged. It would be better to use 'common ancestor' (as the merge-base man page does).

Britton
Message 1 of 1 in “[BUG] git bisect start gives incorrect error message when good/bad swapped”
  1. Britton KerinDec 11, 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.