Making scripts executable inside Subversion

The Problem

Every time you check out a script file from Subversion on a Unix system, the file is missing the execute permission and you have to manually perform a chmod +x every time. This usually happens if the file was either originally added without the permission set or if it was added to Subversion from a Windows system. But more to the point, it is extremely annoying.

The Solution

The solution to this involves adding an internal Subversion property called svn:executable to the script file(s) in question. The property can either be set using Tortoise SVN from a Windows system (as described by a posting on Late Night PC found by my colleague Máté Rácz) or can be done from the command-line as follows:

$ svn propset svn:executable true myscript.sh

Both methods work and required a SVN commit afterwards.

Undeleting a file in Subversion

It would appear that Subversion does not support a direct “undelete” command so here is one way to recover/undelete a file that was previously removed from a Subversion repository. The 955 is the version of the repository where the file last existed.

$ svn cp -r 955 http://svn.domain.com/reponame/pathtofile/foo.bar foo.bar
A foo.bar
$ svn commit -m "Undeleted this file" foo.bar

Best of luck!

Using a different diff with Subversion

If like me, you’re not too keen on the sometimes cluttered output produced by a Subversion diff command (svn diff), here is a way to use Unix diff with Subversion instead. I’ve also used the -b parameter to ignore whitespace differences.

$ svn diff --diff-cmd diff --extensions '-b'

It looks a little messy at first but you could probably alias it quite easily using something like:

alias "svn_diff_b"="svn diff --diff-cmd diff --extensions '-b'"

in your .bashrc (or equivalent) file.