tig + mutt = commit review

I spend some of my time reviewing team members commits. Typically I’d use the RSS feed from Google Reader, but it doesn’t have the actual diff to comment on.

Most of the time I use tig to view
the commits. And instinctively I’d want to email the author with my comments, so here’s how to do that. I’m sure there are easier commands but this is what worked for me, your experience may vary.

First thing I did was create a git alias which is useful by itself. It outputs the commit to a temp file, then gets the title and the author’s email address from the same commit passing that to mutt.

    prepmail = !sh -c 'git show $1 > /tmp/commit && mutt -s \"`git show --pretty=format:\"%s\" $1 | head -n 1`\" -i /tmp/commit -- \"`git show --pretty=format:\"%ae\" $1 | head -n 1`\"' -

Now I want to be able to press a key in tig at the diff screen to reply to the author’s commit.

Simply bind a key, in my case I bound s in the diff view to call git prepmail with the commit’s SHA1.

In your $HOME/.tigrc add the following line. Checkout the tigrc man page for more information.

bind diff s !git prepmail %(commit)

Now in the diff view press ‘s’ and tig will launch mutt with the appropriate information.

The email shows up first:

Followed by the email’s subject, notice it matches the commit’s message.

And finally, the diff as an email body allowing you to comment on the changes
to the author.

So a simple git alias in $HOME/.gitconfig, a key binding for $HOME/.tigrc, and you can now review commits using tig. Enjoy!

Windows is still a pain

So I’m setting up a new Windows 7 machine for my inlaws. This time it’s a new Dell preinstalled with Windows 7, which is great I don’t have to actually install the OS. But Windows still sucks to setup, first I had to figure out how to copy the data from the old machine to the new. In Linux, I would simply rsync the homedirs from the old to the new machine. Thankfully Windows 7 had a “Windows Easy Transfer” program (rsync is still easier) 🙂

After all of the data and user accounts were copied over, Windows Easy Transfer presented me with a list of all the applications I should probably installed based on the settings it found in the data transfer. This was extremely useful, and also where the pain starts. In Linux (Fedora), I would simply setup the appropriate yum repos, then yum install firefox, google-chrome, nvidia-kmod, etc. With Windows I have to go to each of the vendors sites and download their custom setup program. The worst is when you have a few applications to install and they each want you to reboot after each one.  Only 15 more applications to install now 😦