25 July 2009

setting SVN autoprops

I've just enabled the auto-props feature for my local svn installation (see here how to do it). Seriously, this is the 1st thing you should do after you install a subversion client as cleaning up your later, when you have already added hundreds of files to your repository is a tedious task :-(

As usual I googled a little bit for some advise how to do it best and to my suprise I usually found something like this:

[auto-props]
*.java = svn:mime-type=text/plain;svn:eol-style=native;svn:keywords=Date Revision
*.sh = svn:executable;svn:eol-style=native;svn:keywords=Date Revision
(e.g. here)

So what's the problem with that list (except that svn:mime-type is missing for .sh)?
svn:eol-style is set to native which means that files are automatically converted to the platform line end style when they are checked out - e.g. to CRLF on Windows.

Why is this a problem?
Repeatable builds! If you check out the same revision once on Windows and once on Linux you get different artifacts when you build it with e.g. Maven. For Java files this may be no big deal as they are usually compiled into class files, but shell scripts (which get packaged in your Maven artifact) may stop to work correctly if they have suddenly CRLF instead of LF line ends.

So my auto-props configuration looks like this:

*.sh = svn:eol-style=LF;svn:executable
*.txt = svn:eol-style=LF
*.java = svn:mime-type=text/plain;svn:eol-style=LF;svn:keywords=Date Revision Author Id HeadURL
*.xml = svn:mime-type=text/xml;svn:eol-style=LF
*.properties = svn:mime-type=text/plain;svn:eol-style=LF
*.png = svn:mime-type=image/png
*.jpg = svn:mime-type=image/jpeg

Come on guys, there is really no need to use native style on Windows anymore! If your editor/IDE cannot handle LF ends, get a better one!


Note: unfortunately there is currently no way to define auto-props on a repository level (http://subversion.tigris.org/issues/show_bug.cgi?id=1974), so I have to repeat this procedure on my Linux box now

No comments: