For cross-platform projects, I switched from using XCode to TextMate and CMake. I found this to be a more productive environment for me but I miss the OpenDiff integration that’s built into XCode. Most of the time svn diff is all I need, but for more complex changes the visualization provided by OpenDiff makes life so much easier.
It turns out that Subversion keeps a copy of the unedited version of your source code in its .svn directory. That was all I needed to build a command line shortcut to OpenDiff. The original source is kept in .svn/text-base and has a suffix of .svn-base. My first attempt was to create an alias:
$ alias od=’opendiff $1 .svn/text-base/$1.svn-base’
But, it turns out that bash aliases do not support parameter substitution. Who knew?
After a little more digging, I discovered you can define functions in bash. So the shortcut then became:
$ function od { opendiff $1 .svn/text-base/$1.svn-base; }
This did the trick. I can now start OpenDiff with a command like:
$ od source.cpp
Put the function definition in your .profile (or in .bashrc or in any of the many places you can put startup commands).


Ferruccio,
Thanks very much. This is by far the most elegant and easily extensible solution that I have seen.
Gary
Comment by Gary Griswold — November 20, 2009 @ 11:35 am