views:

37

answers:

2

Problem

Frequently (but not every time) when using CVS to check in files like: .java, .cs, .xml, etc, every line of the file is gets a carriage return.

Example:

File before check-in by a team member:

// Begin file
    class Foo
    {
      public Foo()
      {
        // Do step 1
        // Do step 2
      }
    }
// End file

File when checked out by a team member:

// Begin file

    class Foo

    {

      public Foo()

      {

        // Do step 1

        // Do step 2

      }

    }

// End file

Development Environment

  • NetBeans 6.8 and now 6.9 (the problem occurred when using 6.8 as well).
  • Visual Studio 2008 and 2010.
  • Repository: CVS; checkins and checkouts done from Cygwin bash shell.
  • Operating system: Widows XP Professional.

What I Have Tried

I tried changing the value: build.compiler.emacs=true within NetBeans under Tools->Options, thinking this might be causing some kind of Unix/Windows translation problem when checking in? This made no difference.

Am I missing something about what happens to a file when it gets checked into CVS in a Windows/IDE/Cygwin stack that can cause this problem?

Thanks for your help,

-bn

+2  A: 

Something is converting DOS line breaks (CR LF) to pairs of Unix line breaks (just LF). I would personally bet on its being CVS. You might want to try using TortoiseCVS instead of Cygwin CVS.

Zack
+1  A: 

A Windwos-native CVS client will convert MS-DOS line endings in a text file (\r\n) to Unix-style line endings when submitting the file to the server, so that in the repository, the files are maintained in a 'canonical' form with \n representing a line ending. When Windows native client will also convert the line ending when bringing a file down from the server.

However, I believe that the default Cygwin CVS client acts like a Unix client and assumes that no line ending conversion is required. So if you use that client to check in a file with MS-DOS-style endings (\r\n), you'll get this kind of confusion.

It looks like the people who are using the Cygwin client are using tools that care converting the files to MS-DOS style line endings (or something is).

A potential fix is to uninstall the Cygwin CVS client and install the WinCVS client on your Windows/Cygwin boxes so the Windows native client will be used even when a Cygwin shell is active:

Another possibility to to configure your Cygwin mounts under a specific mode (but I'm not really familiar enough with Cygwin to know how well this works or if it might introduce otehr problems - it's been a long time since I've tried using Cygwin):

Michael Burr