Subversion END OF LINE (EOL) problem

Generally, if you have been working on subversion source control long enough, you might seen this error. Most of developers end up doing some work around and forget about it. But what is this problem is.

svn: File “xxx.vsd” has inconsistent newlines svn: Inconsistent line ending style
Subversion whenever adding or commiting file, checks EOL (end of line) style. It can either UNIX (LF) or Windows (CRLF). But if it is not consistent in a file, then it doesn’t know, which style to use while storing. Hence it stops whole committing process and throw this error.

Subversion provides various options for windows and developers for this. First option they provide using svn property ‘svn:eol-style’. This property can be set on a file, whether LF or CRLF.  Subversion will store this file using Operating System native format of line-ending. But different developers can be editing same file on different operating system. Hence subversion provide option of ‘native’ which means, whatever OS is being used, let developer check-in using that but other developer on different OS, will see file, in it’s own native format. Here Subversion is play proxy to EOL format. 

Coming back to error above, this problem won’t be fixed even if, we have svn:eol-style is set. For this either, we open that file and chance EOL to one format. Subversion is confused, by seeing different types of EOL in one single file.
Other solution mentioned in forums is, to use dos2unix utility. Not sure, whether it is even available on Windows platform and certainly, I may not want to commit another version of file, just because of EOL.

What about, if you have hundreds of files?

Subversion has ‘config’ file where you can set values at global scope. Hence you don’t need to set svn:eol-style for different files all the time. This global file resides at ~/.subversion/config file (or %APPDATA%Subversionconfig on Windows) 

Now by default, “enable-auto-props = yes” is set and uncommented. Also you can see at bottom of file, certain file extensions has eol-stype property beingset to ‘native’ But to solve problem of mixed bag of EOLs in different files, you just comment back “enable-auto-props“. So what happens, subversion will NOT try to expect any EOL and let you add/commit a file. Once done, you can un-comment it back.

References:

  1. http://svnbook.red-bean.com/en/1.1/ch07s02.html
  2. https://www.opends.org/wiki/page/ConfiguringSubversionToSetTheCorrectEndOfLineFormat
  3. http://conorcahill.blogspot.com/2007/10/subversion-end-of-line-style.html