Finding when a bug was fixed with git bisect
I don’t have much reason to use git bisect
usually, but today I noticed that
a bug in an open source project had been fixed and I wanted to figure out when.
The main gotcha was that git bisect
usually assumes that you’re trying to
figure out when a bug was introduced (not fixed), so I had to reverse everything.
step 1: Write a script test.sh
that fails if the bug is fixed (so I had to reverse the exit codes):
pip3 install .
if unbuffer sqlite-utils insert test.db test --csv test.csv | grep -o '100.......' | grep 25h
then
# this means the bug is fixed, so fail (reverse the output)
exit 1
else
exit 0
fi
step 2: run git bisect
git bisect start
# we have to mark the current state as "bad" even though it's technically the
# old state that was "bad"
git bisect bad main
git bisect good 0d45ee11
git bisect run test.sh
It worked perfectly and after 10 seconds gave me the exact commit that had fixed the bug.