[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: 1.4.[23] for cygwin doesn't handle eol's properly

From: Frodak Baksik <frodak17_at_gmail.com>
Date: 2007-02-28 14:44:10 CET

On 2/27/07, Kylo Ginsberg <kylo.ginsberg@gmail.com> wrote:
> On 2/27/07, Nathan Kidd <nathan-svn@spicycrypto.ca> wrote:
> > Kylo Ginsberg wrote:
> > > I am running Cygwin with DOS as the default text file type when I see
> > > this problem. (I thought that was implied by specifying that it is a
> > > textmode cygwin mount?) Hope that clarifies.
> >
> > I don't think textmode implies anything. If you set DOS mode then
> > textmode will produce CRLF, if you set UNIX mode then textmode will give
> > you LF.
>
> I am not a cygwin expert, but this does not match the behavior on my
> cygwin installation. What I see is:
>
> Changing to DOS mode sets the default cygwin mounts to "textmode" and
> changing to UNIX mode sets the default cygwin mounts to "binmode".
> Independently, you can specify additional mounts in the mode of choice
> (textmode/binmode).
>
> On a textmode mount "echo foo > foo" produces a 5 character file
> ending 0d 0a. This is true regardless of the DOS vs UNIX setting in
> setup.
>
> On a binmode mount "echo foo > foo" produces a 4 character file ending
> 0a. This is true regardless of the DOS vs UNIX setting in setup.
>
> From all this I tentatively conclude that the DOS vs UNIX setting
> *only* sets the mount types for the default mounts. At least I
> haven't confirmed that it does anything else.

That's what I've always read on the cygwin mailing list. Also,
programs will only perform EOL conversion when reading and writing in
text-mode and not in binary mode. It seems to me that most programs
tend to perform binary mode read / writes.

You can verify this by using echo, cat, and md5sum.
echo "blah" > file -- writes in text-mode - creates files with \r\n on
text-mode mounts and \n on binary mounts
cat > file -- writes in binary mode - creates files with \n on either
mount types
md5sum file -- reads in binary mode
md5sum -t file -- reads in text mode

$ echo blah > textmode/crlf.txt

$ xxd textmode/crlf.txt
0000000: 626c 6168 0d0a blah..

$ cat > textmode/lf.txt << HERE
> blah
> HERE

$ xxd textmode/lf.txt
0000000: 626c 6168 0a blah.

fbaksik@F-BAKSIK ~
$ md5sum.exe -b textmode/crlf.txt
8302053932358b0263f94e500fbb3aef *textmode/crlf.txt

fbaksik@F-BAKSIK ~
$ md5sum.exe -t textmode/crlf.txt
0d599f0ec05c3bda8c3b8a68c32a1b47 textmode/crlf.txt

$ md5sum.exe -b textmode/lf.txt
0d599f0ec05c3bda8c3b8a68c32a1b47 *textmode/lf.txt

$ md5sum.exe -t textmode/lf.txt
0d599f0ec05c3bda8c3b8a68c32a1b47 textmode/lf.txt

Notice that reading lf.txt in either mode and reading crlf.txt in text
mode produces the same md5sum, while crlft.txt in binary mode has a
different value.

> > Are you saying the following is true?
>
> Originally, I was checking out a file previously checked in with
> svn:eol-style set to native and seeing LF line endings.
>
> But I tried your should-be-simple experiment:
>
> >
> > echo -e "line 1\nline2\n" > test.txt # test.txt has CRLF
> > svn add test.txt
> > svn ps svn:eol-type=native test.txt
>
> I replaced this with:
> svn ps svn:eol-style native test.txt
>
> > svn ci -m"test" test.txt
>
> And at commit time, I get:
> svn: Can't parse [...].svn/tmp/props/test.txt.svn-work
> svn: Malformed file
>
> I tried hand-editing the CRs out of this file but still had this
> problem with the commit (and so couldn't carry out the test). This
> problem is a new one.
>
> > rm test.txt
> > svn up test.txt # now test.txt has LF
> >
> > In that case I suppose it would be an issue with APR deciding that
> > APR_EOL_STR will be "\n" instead of "\r\n".

Cygwin is a POSIX compatibility layer and EOLs should be \n.

> So I took at look in the source at subversion/libsvn_subr/subst.c, and
> I see that the eol string for native is set to APR_EOL_STR. And sure
> enough APR_EOL_STR is defined as "\n" for this build.
>
> So I edited APR_EOL_STR to "\r\n" and rebuilt. This gives me the
> desired behavior for the original issue (checkout of files with
> svn:eol-style set to native now checkout with CRLF line endings), but
> I still can't commit a file with a property set (i.e. I get the
> "Malformed file" error message).
>
> At this point, the best workaround I have for this mess is to use the
> windows-compiled subversion under cygwin, which appears to work for
> cygwin textmode mounts. It doesn't know about cygwin paths of course,
> but fortunately it parses forward slashes as back slashes so it works
> in most practical settings.
>
> Any other suggestions? Or successful experience with subversion in
> the cygwin environment?
>
> Thanks
> Kylo
>

If you want your files on checkout to have \r\n you can either set
svn:eol-style to CRLF or try the patch w/ Issue 2708.

--
Frodak
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Wed Feb 28 15:05:25 2007

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.