Home > English, Tech Crunch > Subversion and the incoherent linebreak problem

Subversion and the incoherent linebreak problem

When trying to commit code into a subversion repository, and if the code you want to submit comes from third parties, you might occasionally run into the error “incoherent linebreak”.

This is due to people editing files from Windows, Linux and Mac, which all have different line break characters. Under Windows, it’s \r\n, under Mac it’s \r and finally under Linux it’s \n.

Depending on what system you are usually using to commit your code to SVN, you should replace all the others for yours. This is easily done by asking all external contributors to change their text editor settings to “Linux linebreaks” for example.

If the code you are trying to submit comes from a PHP generator (some translation interface), you can use the following code to do that:

$string = str_replace(array("\r\n","\r"),array("\n","\n"),$string);

If you are reviewing files with VIM, you should be able to do something like:

:% s/\r\n/\n/g
:% s/\r/\n/g

Then try to commit again. The incoherent linebreak error should have disappeared.

Categories: English, Tech Crunch
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: