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

Re: Why can't I use git-bisect to find the first *good* commit?

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Mar 28, 2011, 20:37 UTC
Message-ID
<vpqvcz3x9q0.fsf@bauges.imag.fr>
In-Reply-To
<AANLkTim+iQ89b49nC8NRtoUobV4tMVL+bCoW-vg3+rLD@mail.gmail.com>
Andrew Garber <andrew@andrewgarber.com> writes:
Show 8 quoted lines
> But what about demerphq's example? (see below)
>
>>      Bx--B--B--B*
>>     /
>>  --Gz--By--B--Gx--G*
>>
>> How does knowing that G* is good help you to find that Bx broke the
>> code in the B* branch again?

If all you want is to know which commit introduced the bug, it doesn't. But usually, what you're really looking for is an explanation and a fix for the bug. Let's see what git bisect tells us then:

$ git bisect start
$ git bisect good <good-branch>
$ git bisect bad <bad-branch>
Bisecting: a merge base must be tested
[f1fac16fb39dbe421b5cc4bcb945433495c794e1] ...
$ git bisect bad
The merge base f1fac16fb39dbe421b5cc4bcb945433495c794e1 is bad.
This means the bug has been fixed between f1fac16fb39dbe421b5cc4bcb945433495c794e1
 and [089840ef9f8b97ddc9e28fa152c65115fb0b649a].

This doesn't tell you where the bug was introduced, but gives you something which is usually even more valuable: where to find the fix. Then, you have the choice between merging the good branch into the bad one (like merging a maintainance branch into a dev branch), or to bisect again to find the actual fix in good-branch.

If you really wanted to find the first bad commit, you've spent one iteration sub-optimally and can start a new bisect with the merge base as the base commit.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Jeff KingNext: Andreas Ericsson
Message 21 of 23 in “Why can't I use git-bisect to find the first *good* commit?”
  1. Ævar Arnfjörð BjarmasonMar 28, 2011
  2. Andreas EricssonMar 28, 2011
  3. code.sculptor@gmail.comMar 28, 2011
  4. Matthieu MoyMar 28, 2011
  5. Vincent van RavesteijnMar 28, 2011
  6. Christian CouderMar 28, 2011
  7. Andrew GarberMar 28, 2011
  8. Johannes SixtMar 28, 2011
  9. Andrew GarberMar 28, 2011
  10. Matthieu MoyMar 28, 2011
  11. Andrew GarberMar 28, 2011
  12. Matthieu MoyMar 28, 2011
  13. Andrew GarberMar 28, 2011
  14. Matthieu MoyMar 28, 2011
  15. demerphqMar 28, 2011
  16. Andrew GarberMar 28, 2011
  17. Matthieu MoyMar 28, 2011
  18. Andrew GarberMar 28, 2011
  19. Jeff KingMar 28, 2011
  20. Jeff KingMar 28, 2011
  21. Matthieu MoyMar 28, 2011
  22. Andreas EricssonMar 29, 2011
  23. Michael WittenMay 22, 2011

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.