Subversion line-ending style: dos versus unix

Not all of the various editing tools understand that files may contain line endings in a format that differs from the native line-ending style of the operating system on which they are running. So, typically, Unix programs treat the CR character present in Windows files as a regular character (usually rendered as ^M), and Windows programs combine all of the lines of a Unix file into one giant line because no carriage return-linefeed (or CRLF) character combination was found to denote the ends of the lines.

This sensitivity to foreign EOL markers can be frustrating for folks who share a file across different operating systems. For example, consider a source code file, and developers that edit this file on both Windows and Unix systems. If all the developers always use tools that preserve the line-ending style of the file, no problems occur. But in practice, many common tools either fail to properly read a file with foreign EOL markers, or convert the file's line endings to the native style when the file is saved.

(2008-10-01) Some files in the Tribler repository use the unix line-ending, while others use the windows line-ending. Even worse, some files contain a mixture of both unix and windows line-endings. An earlier attempt to solve this failed because an invalid svn property was used (eol-type = native). This should have been svn:eol-style = native.

(2008-10-08) The solution described has been applied to the mainbranch.

Setup line-ending for a svn source tree

To solve this problem we use the following commands to use the unit line-ending on all text-files prior to committing them with the correct svn property svn:eol-style = native. This will avoid this problem in the future.

Include(, text/txt)

Merging files with different line-endings

When merging files with different line-endings each line will be marked as changed. This makes it very difficult to find the actual changes. However, svn can be ordered to ignore the line-endings when doing a diff or merge.

# diff: ignoring line-endings

svn diff -x --ignore-eol-style OLD-URL[@OLDREV] NEW-URL[@NEWREV]

# merge: ignoring line-endings

svn merge -x --ignore-eol-style sourceWCPATH1@N sourceWCPATH2@M [WCPATH]