Wednesday, 8 October 2008

Getting svn:externals to work with git-svn and... Leopard

There IS a simple solution to work conveniently in git-svn with repository that has svn:externals set. You can clone all repositories to seperate trees, and instead of watching svn:externals, make hard links to the trees you need (remember to ignore them in git). The problem is you can't have hard links to directories... unless you're using OS X Leopard (they implemented it in order to get Time Machine to work).

This ability isn't exposed to the command line (ln makes an explicit check to prevent you from doing that), but the code to have it working(scroll down to listing 4) is trivial.

Update: When working with hard-linked directories, remember to be careful when unlinking them: rm wouldn't unlink the directory unless provided with "-r" option, which deletes everything recursively, leaving other hard links to that directory empty.