Subversion/auto-props
This page is obsolete. It is being retained for archival purposes. It may document extensions or features that are obsolete and/or no longer supported. Do not rely on the information here being up-to-date. MediaWiki used the Subversion version control system, but has since migrated MediaWiki core and nearly all extensions to Git. |
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.
Finding your config file
[edit]Command-line (Unix/Mac)
[edit]~/.subversion/config
or /etc/subversion/config
TortoiseSVN (Windows)
[edit]%appdata%\Roaming\Subversion\config
Click the 'edit' button for 'Subversion configuration file' in the settings dialog:
Setting auto-props
[edit]In [miscellany] uncomment/add this line:
enable-auto-props = yes
In the [auto-props] section, uncomment the default bits and also add:
*.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 Makefile = svn:eol-style=native SConscript = svn:eol-style=native SConstruct = svn:eol-style=native USERINFO = svn:eol-style=native
Make sure none of the lines start with spaces, or you will get an error message.
Fixing a broken file
[edit]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