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

Re: git bisect should return 1 when the first bad commit is found

From
Jeff King <peff@peff.net>
Date
Jun 25, 2019, 04:58 UTC
Message-ID
<20190625045848.GA7571@sigill.intra.peff.net>
In-Reply-To
<CAP8UFD1gWnkJZSzjOxOHdS4R3GCUSDgC9X85y_Yvc0LmyK19Cw@mail.gmail.com>
On Mon, Jun 24, 2019 at 09:16:13AM +0200, Christian Couder wrote:
Show 8 quoted lines
> So you just need to parse stdout to detect that it found the first bad
> commit, and then you can use refs/bisect/bad.
>
> If the return code was used, how would you distinguish between a
> failure in the command (for example if you give bad information to
> `git bisect good` or `git bisect bad`) and the fact that it has not
> yet found the first bad commit? Anyway you would need to add some
> logic for that.

Right, thanks for reminding us of that ref. I did leave a suggestion elsewhere in the thread that we might be able to avoid the exit-code pitfalls by using a specific "result" ref.

> If it would be HEAD, it would mean that git bisect would potentially
> have to do one more checkout so that HEAD points to the first bad
> commit. This checkout would sometimes be useless, so it's more
> efficient to use something like refs/bisect/bad rather than HEAD.

I'm not too concerned with the cost of checking out a tree. After all, we've just done a bunch of checkouts and probably some operations on the tree itself. But I think there's a much more important reason my suggestion may have problems.

Sometimes we _can't_ checkout another commit, because part of testing the bisection may involve mucking with the working tree. For instance, earlier today I was bisecting a case where git.git did not show the breakage itself, but applying a debugging patch on top did. So I was bisecting along the real history, adding new contents, testing, and then cleaning up my changes before jumping to the next bisection candidate.

On the other hand, I have to clean them up anyway before running "git bisect good" or it cannot jump to the next candidate when we are not finished. Jumping to "bad" when we _are_ finished is no different there. But I think it does show that there can be surprising implications to moving HEAD around.

-Peff
Previous: Christian CouderNext: Junio C Hamano
Message 6 of 9 in “git bisect should return 1 when the first bad commit is found”
  1. Pedro LarroyJun 12, 2019
  2. Junio C HamanoJun 13, 2019
  3. Pedro LarroyJun 23, 2019
  4. Jeff KingJun 23, 2019
  5. Christian CouderJun 24, 2019
  6. Jeff KingJun 25, 2019
  7. Junio C HamanoJun 24, 2019
  8. Jeff KingJun 25, 2019
  9. Junio C HamanoJun 25, 2019

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.