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:

Makefile = svn:eol-style=native SConscript = svn:eol-style=native SConstruct = svn:eol-style=native USERINFO = svn:eol-style=native
 * .css = svn:eol-style=native
 * .eot = svn:mime-type=application/vnd.ms-fontobject
 * .gif = svn:mime-type=image/gif
 * .ico = svn:mime-type=image/vnd.microsoft.icon
 * .inc = svn:eol-style=native
 * .info = svn:eol-style=native
 * .install=svn:eol-style=native
 * .java = svn:eol-style=native
 * .jpeg = svn:mime-type=image/jpeg
 * .jpg = svn:mime-type=image/jpeg
 * .js = svn:eol-style=native
 * .jsp = svn:eol-style=native
 * .module = svn:eol-style=native
 * .php5 = svn:eol-style=native
 * .php = svn:eol-style=native
 * .pl = svn:eol-style=native
 * .pm = svn:eol-style=native
 * .png = svn:mime-type=image/png
 * .py = svn:eol-style=native
 * .sh = svn:eol-style=native
 * .sql = svn:eol-style=native
 * .svg = svn:mime-type=image/svg+xml
 * .tpl = svn:eol-style=native
 * .ttf = svn:mime-type=application/x-font-ttf
 * .txt = svn:eol-style=native
 * .woff = svn:mime-type=application/x-woff
 * .xcf = svn:mime-type=image/x-xcf

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