Archive for the ‘Code’ Category

git and Changes.app: take two, the right way to do it

Wednesday, February 27th, 2008

Well, thanks to a pointer I found out that my git-chdiff script is a bit overblown. You see, a person can just use the built in functionality of git, namely setting the GIT_EXTERNAL_DIFF environment variable to point to something that can take the seven command line arguments git will pass on to whatever you’ve set as your external command. It’s beautiful in its simplicity:


#!/bin/sh
[ $# -eq 7 ] && /usr/bin/env chdiff –wait “$2″ “$5″

Just stick that in a script file, make it executable, set the GIT_EXTERNAL_DIFF environment variable to point at it and away you go. I’ve also documented it in the Changes.app wiki. I feel so silly for not finding this before, but the exercise in a scripted solution was good for me.

git-chdiff: using Changes.app with git

Thursday, February 21st, 2008

Earlier this week I mentioned that Changes 1.0 shipped. I had already updated the wiki SCM integration page with instructions on how to use Perforce with the chdiff utility.

Last night I was messing around at home and trying to use the contributed script for diffing a project with Git1 but it just wasn’t working the way I wanted. I generally like to work by being in the code tree and diffing a file against what was the last checkin (Or alternately a tagged checkin). The script that was there would do a comparison of the whole tree. I do find that valuable and I’ll keep it around for when I need that, but for my day to day work I want to just quickly view what changed from what I have on disk and what is in the repository at some point.

With that in mind I went and wrote up a quick python script that basically does what I want. I’m sure there is room for improvement and I might not have gotten everything right, but that’s why I put it up on the wiki. You can access the code directly from me if you like.

git-chdiff.py

Enjoy.

UPDATE - this only works in the root of the git project. I’ll post an update that works in subdirs when I have it.

UPDATE 2 - fixed now and uploaded.

Footnotes:
  1. I’ll have another post soon detailing why I decided to go with Git.