Another Japan in the World

Jun Aruga's blog.

How to use "git bisect".

I used git bisect command related to this issue on the Ruby project.

The situation is that the some tests in test/ruby/test_jit.rb fail on the v2_7_4 tag, but pass on v2_7_3 tag on the ruby/ruby repository. So, here is steps to find which commit between v2_7_3 and v2_7_4 causes the failure.

First prepare a script to judge the result.

$ cat ~/work/test.sh
#!/bin/bash

set -ex
  
git clean -fdx
autoconf
./configure --enable-shared --prefix $(pwd)/dest
make
make test-all TESTS="-v test/ruby/test_jit.rb -n TestJIT#test_compile_insn_local"

Then run the following command. The syntax of git bisect start is git bisect start [<bad-commit> [<good-commit>]].

$ git bisect start v2_7_4 v2_7_3

$ git bisect run ~/work/test.sh
...
29bbad939939c6dceb804aac667ba372fdee4ef5 is the first bad commit
...
bisect run success 

Here is the log.

$ git bisect log
# bad: [a21a3b7d23704a01d34bd79d09dc37897e00922a] Fix StartTLS stripping vulnerability
# good: [6847ee089d7655b2a0eea4fee3133aeacd4cc7cc] merge revision(s) 856a9701fd13edbb9d5f0fa773082d312195df90:
git bisect start 'v2_7_4' 'v2_7_3'
# bad: [d8bbbc308e99635091fe9c6e89ee8d711cc008b9] bump patchlevel for previous merge commit
git bisect bad d8bbbc308e99635091fe9c6e89ee8d711cc008b9
# good: [67f1cd20bfb97ff6e5a15d27c8ef06cdb97ed37a] merge revision(s) fbbc37dc1d5b329777e6d9716118db528ab70730: [Backport #17802]
git bisect good 67f1cd20bfb97ff6e5a15d27c8ef06cdb97ed37a 
# bad: [29bbad939939c6dceb804aac667ba372fdee4ef5] Fix 2.7 build (#4359)
git bisect bad 29bbad939939c6dceb804aac667ba372fdee4ef5
# good: [fd95a1805922d9fbe65e6f4c08609c7eac10b723] merge revision(s) d8a13e504992a45d52063f7c925408d7aad3595a: [Backport #17780]
git bisect good fd95a1805922d9fbe65e6f4c08609c7eac10b723 
# first bad commit: [29bbad939939c6dceb804aac667ba372fdee4ef5] Fix 2.7 build (#4359)

The following status is to turn back to normal.

$ git bisect reset

References