[Mono-list] A possible reason for getting newline problems

Martin Baulig martin@gnome.org
06 Mar 2002 00:32:55 +0100


Hi guys,

after this thread about Unix/Windows newline conventions a few days
ago I found a possible reason for these problems.

As I already mentioned earlier, I'm using an editor (GNU Emacs) which
correctly handles DOS files and saves the file without changing the
newline convention.

However, as I wanted to commit my Array.cs changes (the file is in
Unix mode) and looking at the patch, I realized that the whole file
was converted to DOS mode.

Since my editor cannot be responsible for this, the only possible
reason was the cvs checkout from anoncvs on Windows.

So the first thing I did was converting the file back to Unix
conventions, looking at the `cvs diff -u' output and then committing.

After that, I removed the file on my Windows box and checked it out
again from CVS - and it was in DOS mode again :-(

So I looked at this again - and finally found the reason:

The standard mode for CVS is to do so-called keyword substitutions
(so that things like $Id$ in a file are replaced) - and this also
changes the whole file to Windows line endings.

So you need to use the -kb flag on every checkout and update.

It's best to put something like this into your ~/.cvsrc:

====
cvs -z3
update -d -P -kb
checkout -kb
diff -u
====

Of course you also need to use an editor which can handle Unix line
endings - but the best editor is useless if the file is already
converted on checkout ...

-- 
Martin Baulig
martin@gnome.org