Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert all line endings to CRLF, LF, or CR during SVN operations

Tags:

So, you are all ready to do a big SVN Commit and it bombs because you have inconsistent line endings in some of your files. Fun part is, you're looking at 1,000s of files spanning dozens of folders of different depths.

What do you do?

like image 412
Brett Veenstra Avatar asked Aug 19 '08 04:08

Brett Veenstra


People also ask

Why does git change LF to CRLF?

Git doesn't expect you to use unix-style LF under Windows. The warning "CRLF will be replaced by LF" says that you (having autocrlf = input ) will lose your windows-style CRLF after a commit-checkout cycle (it will be replaced by unix-style LF). Don't use input under Windows.

Should I use CRLF or LF?

Whereas Windows follows the original convention of a carriage return plus a line feed ( CRLF ) for line endings, operating systems like Linux and Mac use only the line feed ( LF ) character. The history of these two control characters dates back to the era of the typewriter.

What is CRLF and LF?

CR = Carriage Return ( \r , 0x0D in hexadecimal, 13 in decimal) — moves the cursor to the beginning of the line without advancing to the next line. LF = Line Feed ( \n , 0x0A in hexadecimal, 10 in decimal) — moves the cursor down to the next line without returning to the beginning of the line.


1 Answers

I don't think the pre-commit hook can actually change the data that is being committed - it can disallow a commit, but I don't think it can do the conversion for you.

It sounds like you want the property 'svn:eol-style' set to 'native' - this will automatically convert newlines to whatever is used on your platform (use 'CRLF', 'CR' or 'LF' to get those regardless of what the OS wants).

You can use auto-properties so that all future files you create will have this property set (auto props are handled client-side, so you'd have to set this up for each user).

like image 144
Cebjyre Avatar answered Sep 19 '22 19:09

Cebjyre