Hunting for the commit that broke something by hand is a bit like reading a book to find a typo. git bisect does a binary search, and it can run the check by itself.
git bisect start HEAD v1.2 --
git bisect run ./test.sh
git bisect reset
The first line says HEAD is bad and the tag v1.2 was good. The second line gives git a script. Git checks out a commit halfway, runs your script, reads the result, and repeats with the next half until one commit is left. The last line takes you back to where you started.
The script talks to git through its exit code. According to the docs, 0 means good, and a code between 1 and 127 except 125 means bad. Any other code aborts the bisect. 125 is special: it means this commit cannot be tested, so skip it.
#!/bin/sh
make || exit 125 # does not build: skip
./check_test_case.sh
A build that fails halfway through history is the usual reason for that 125. Without it, git would blame a commit for a failure that has nothing to do with your bug.
The caveat: the script has to give the same answer every time. A flaky test sends the search the wrong way and you land on an innocent commit. Run it by hand a few times first.
Further reading: git bisect documentation, On this site: git commit –fixup plus –autosquash keeps your history clean without any editing, On this site: follow one function through history with git log -L, On this site: Guide: let git bisect find the commit that broke your code