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

Re: Possible git bisect behavior issue when skipping commits

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 21, 2025, 17:03 UTC
Message-ID
<xmqqa54xzdaf.fsf@gitster.g>
In-Reply-To
<CAP8UFD1bwe92zbXHWe-LiMSJZtcTJQwi9mtgNCm-_kTeyFk08w@mail.gmail.com>
Christian Couder <christian.couder@gmail.com> writes:
Show 37 quoted lines
>> # Commit 1 – good
>> echo "good" > file.txt
>> git add file.txt
>> git commit -m "Commit 1 - good"
>>
>> # Commit 2 – skipped
>> echo "middle" > file.txt
>> git add file.txt
>> git commit -m "Commit 2 - middle"
>>
>> # Commit 3 – bad
>> echo "bad" > file.txt
>> git add file.txt
>> git commit -m "Commit 3 - bad"
>>
>> # Start bisect
>> git bisect start
>> git bisect bad
>> git bisect good HEAD~2
>
> When both one "good" and one "bad" commits have been specified, then
> Git starts bisecting, which means that you should then see something
> like:
>
> Bisecting: 0 revisions left to test after this (roughly 0 steps)
> [df357f37981b7f1e804684cc09842d02fd012146] Commit 2 - middle
>
> and Git should have checked out "Commit 2 - middle", so HEAD should
> point to that commit.
>
> By the way it could help if you could show git's output when giving
> steps to reproduce like this.
>
>> git bisect skip HEAD~1
>
> This will "skip" the commit before the current one, so "Commit 1 -
> good", which is already marked as "good".

Good eyes. I missed that "HEAD~1 no longer means the second one at that point because you gave both bad and good already", which you correctly identified as the root cause of the confusion. The user thought #2 is marked to be skipped, but in reality #1 that is good is marked for skipping, which would result in nonsensical output, as the final output phase assumes that all skipped ones haven't been even tested.

Avoid this (I am not saying we should implement such a safety measure, at least not yet) would involve "Are you sure? You've already said X is A but now you are saying it is B" confirmation when "git bisect {good,bad,skip}" is used on a commit that the user already said something about. Allowing them to change their mind is a good feature. We'd need to make consistent changes. For example, when we create refs/bisect/bad, we should check if we already have refs/bisect/good-* that points at the same commit (and vice versa) to make sure we do not mark the same commit as both good and bad. The same thing can be said about "refs/bisect/skip-*".

This is a tangent, but do we forbid using the word "skip" as a customized term for "good"? If we are not, we probably should.

Thanks.
Previous: Christian Couder
Message 4 of 4 in “Possible git bisect behavior issue when skipping commits”
  1. Begad HabibJul 19, 2025
  2. Junio C HamanoJul 20, 2025
  3. Christian CouderJul 20, 2025
  4. Junio C HamanoJul 21, 2025

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.