Friday, April 12, 2013

Keeping the file execution permission in subversion

Subversion won't store the execution bit which is used in Unix, OSX and Linux Systems unless we use a property:
svn propset svn:executable yes
I always say that it is useful to use extensions in files. Even if you can set executable permission in any file the time will come when you need to know which files you should set this property in. This allows you to for example set the flag on for all shell scripts starting from the current directory:
find . -name "*.sh" | xargs svn propset svn:executable yes
If you are creating a new file then you should consider adding the execution flag from the operating system. Then, and only then, proceed to run the 'svn add' command. Subversion will automatically add the executable property to svn. Here is the POC:
$ rm -f
$ touch
$ chmod +x 
$ svn add 
$ svn proplist
Properties on '':
Now you should be able to explain why sometimes your executables might come back from SVN without the +x flag/bit. If you are using an IDE you will need to look at what it is doing behind scenes with a file. For example if you copy an existing file with the svn executable flag from Eclipse into a new file, once Eclipse commits the new file it will end up with the right svn flag on SVN.

If on the contrary you create a brand new file in Eclipse, commit that file and later on you change the file permissions, then Eclipse won't set the svn:executable flag. This is the behavior for at least the subversive plugin (the one I currently use). I would say this functionality (SVN Client to automatically set the svn:executable property obeying the file system execution bit in Unix/OSX/Linux) is a good candidate for a feature request if you ask me. What IDEs would do this for you? Good question for a community forum.

Probably it is worth mentioning that when you checkout or export an existing file containing the svn executable flag, the subversion client will set the OS executable bit for you.

1 comment:

BillyT said...

This was very useful. Thanks for sharing.