Subversion/auto-props

By default Subversion doesn't set the metadata for automatic line endings on added files. In a group like ours with mixed Linux/Unix/Mac and Windows developers, this can make for surprises where some files end up with DOS line endings hardcoded in.

If you don't want to remember to set it manually on every file you add, you can enable the "auto-props" feature in Subversion's configuration file. This can automatically set the line ending (for text files) or MIME type (for binary files) based on file extensions.

Command-line (Unix/Mac)
or

TortoiseSVN (Windows)
Click the 'edit' button for 'Subversion configuration file' in the settings dialog:



Setting auto-props
In [miscellany] uncomment/add this line:

enable-auto-props = yes

In the [auto-props] section, uncomment the default bits and also add:

SConscript = svn:eol-style=native SConstruct = svn:eol-style=native USERINFO = svn:eol-style=native Makefile = svn:eol-style=native
 * .pas = svn:eol-style=native;svn:mime-type=text/pascal
 * .php = svn:eol-style=native
 * .php5 = svn:eol-style=native
 * .inc = svn:eol-style=native
 * .py = svn:eol-style=native
 * .css = svn:eol-style=native
 * .js = svn:eol-style=native
 * .java = svn:eol-style=native
 * .jsp = svn:eol-style=native
 * .sql = svn:eol-style=native
 * .tpl = svn:eol-style=native
 * .txt = svn:eol-style=native
 * .sh = svn:eol-style=native
 * .module = svn:eol-style=native
 * .info = svn:eol-style=native
 * .install=svn:eol-style=native
 * .xcf = svn:mime-type=image/x-xcf
 * .ico = svn:mime-type=image/vnd.microsoft.icon
 * .gif = svn:mime-type=image/gif
 * .png = svn:mime-type=image/png
 * .jpg = svn:mime-type=image/jpeg
 * .jpeg = svn:mime-type=image/jpeg

Make sure none of the lines start with spaces, or you will get an error message.

Fixing a broken file
If you find a file that was incorrectly checked in, it's not too hard to fix.

First, change the file to the correct line-ending style for your platform. Any programming editor should be able to switch styles with some built-in command, or you can use a 'fromdos' or 'todos'-type utility.

Once it's fixed, set the property and check it in:

svn propset svn:eol-style native filename svn commit filename