Re: Possible git bisect behavior issue when skipping commits
From: Junio C Hamano <hidden>
Date: 2025-07-21 17:03:54
Christian Couder [off-list ref] writes:
quoted
# 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~2When 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.quoted
git bisect skip HEAD~1This 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.