GIT is a wonderful tool. It enables some really powerful, flexible working models. There is one model that is commonly used when developing a major feature (or large refactor):

  • Create a long series of patches in the order that it makes sense to develop them.

  • Rebase, reorder, and merge patches into the order that it makes sense to review them.

  • Post patches for review in small, easy to digest groups.

There is a danger in this process. While reordering patches it is very easy to create a tree that won't build at intermediate commits. Since the entire group of patches gets pushed at once, this may not seem like a problem. However, having intermediate commits not build makes it impossible to bisect when failures are found later.

Having every commit along a long patch series build is an absolute requirement.

However, it's kind of a pain in the ass to manually build the tree at every step. The emphasis in the previous sentence is manually. In some sense the ideal tool is something like a scripted bisect. This doesn't work, of course, because both ends of the commit sequence, in bisect terminology, are good.

To get around this in Mesa, I wrote a script that builds origin/master and every commit in some range of SHA1s. If any build fails, the script halts. At the end, it logs the change in the compiler warnings from origin/master to each commit (as I write this, it occurs to me that the warning diffs should be between sequential commits). This is useful to prevent new warnings from creeping in.

My script is available. This particular script is very specific to Mesa, but it should be easy to adapt to other projects. The script is run as:

check_all_commits.sh /path/to/source /path/to/build firstSHA..lastSHA

git rebase -i also has an x/exec step you can use, so with a tiny vim regex, I just rebase -i my branch like so:
pick abcdef Fix something
x autoreconf -vfi && make -C obj clean all check
pick deadbe Fix yet another thing
x autoreconf -vfi && make -C obj clean all check

etc etc. It'll halt the rebase if the build fails.

Comment by daniels Thu Oct 27 03:53:12 2011
I wrote a tool which logs any output of a command into a special ref inside git. It holds not only the output but als a tree of the input files (ie. worktree) which may have changed or untracked files, start and end time and the success of the command. I put it into the GIT wiki (see git-build) but the wiki is still down, and also in a public repository, but that server is down too. If your interessted, I can send you a copy.
Comment by Bert Wesarg Thu Oct 27 12:48:38 2011

see also http://wiki.eclipse.org/EGit/Contributor_Guide#Granularity_of_Changes :-)

I like that. That states things very concisely. Before making this script, I've been very good about all but the 4th point. I should have that nailed down too.

Comment by IanRomanick Fri Oct 28 10:47:53 2011
That's a lot simpler than my script! I like it. I should have known that GIT already had a tool for that. I wonder if GIT can mop my kitchen floor too... probably...
Comment by IanRomanick Fri Oct 28 10:49:21 2011