Automating Git Bisect

I've written a couple of times about Git bisect. It's a way of finding the commit that introduced an error. It works by (essentially) doing a binary search on the commit history. Now, Curtis Poe over at Ovid shows us how to partially automate the process.

The Git bisect process involves testing each candidate commit and marking the result as good or bad. Usually this process doesn't involve a large number of steps (being a log2 n process) but it can be (in Poe's words) boring. Happily, you can often automate the process and avoid the tedium. You do this by writing a script that tests each commit and then just tell Git to run the script on each candidate commit and tell you when it finds the commit that introduced the error. See Poe's post for the details.

This doesn't always work because sometimes it's hard to write a script that will reliably detect an error and sometimes because the test may fail in different ways. To help with the second case, Poe provides a perl script that will look for some specific output or, alternatively, a pattern. If you do a lot of testing using Git bisect, you should give Poe's post a read. Even if you only occasionally use Git bisect, using the automation that Poe describes may save you some time and effort. If you're a Magit user, the bisect function—including the run command that automates the process—is built in.

This entry was posted in Programming and tagged , , . Bookmark the permalink.