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

Re: setting the EOL property throughout a repo?

From: David Weintraub <qazwart_at_gmail.com>
Date: Tue, 25 Nov 2008 15:23:46 -0500

> Users who change the line endings of a file with the svn:eol-style property
> partially to another line ending style (e.g. some lines ending with LF, some
> ending with CRLF; some fantastic Windows editors like to do this) will
> encounter an error message from Subversion telling them the file has
> inconsistent line endings; the user must resolve this problem before
> committing.

My experience seems to indicate that Subversion does not complain as
long as the svn:eol-style is set to either LF or CRLF. However, it
does complain when svn:eol-style is set to "native". Has anyone seen
Subversion complain when svn:eol-style is not set to "native"?

As Ryan Schmidt stated, you need a pre-commit hook to keep your line
endings in good shape after a check in.

Once you add the svn:eol-style property, you probably don't have to
run dos2unix unless you set svn:eol-style to "native". I usually set
svn:eol-style to LF instead of "native" because I don't want Windows
people using Notepad for editing files text files. There are plenty of
good open source program editors that work on Windows, and developers
should be using them.

Once you have the pre-commit trigger on your repository, you can
either fix all files yourself by checking them all out, adding the
svn:eol-style property, and committing the changes, or simply make
your developers do it as they fix files one-by-one.

I opt for the latter because I am lazy and I really don't see a need
of a checkout to fix things that aren't really broken. I may fix the
line ending on those files that are truly broken (like shell scripts
and Makefiles), but I'll skip over XML or HTML files that work despite
their confusing line endings. Let the developers add the svn:eol-style
property when they get edited.

--
David Weintraub
qazwart_at_gmail.com
On Tue, Nov 25, 2008 at 12:56 PM, Ryan Schmidt
<subversion-2008c_at_ryandesign.com> wrote:
> On Nov 25, 2008, at 07:18, Robert P. J. Day wrote:
>
>> On Tue, 25 Nov 2008, Giulio Troccoli wrote:
>>
>>> I've done a little test. I used dos2unix to change the EOL of a text
>>> file, set the svn:eol-style property to LF and commit. You can't
>>> have mixed EOL style when you set the property I seem to remember.
>>> All this on a Unix system.
>>>
>>> Then I change the EOL style with unix2dos but svn status did not
>>> report any changes.
>>>
>>> I'm not sure what this proves though. Maybe that once svn:eol-style
>>> is set Subversion doesn't care anymore about the actual EOL, because
>>> when you check the file out (or maybe even just an update) the EOL
>>> will be what the property says.
>>
>>  i just did a test as well, and it does what i was hoping for.
>>
>> 1) take a non-propertied text file, "unix2dos" it to get <CR><LF> EOL
>> characters in it, use "svn diff" to see that, yes, they're there, and
>> commit that.
>>
>> 2) use "svn cat" on the repo itself to verify that, yes, it got
>> committed with the <CR><LF> EOLs.  so far, so good.
>>
>> 3) check my working copy and, not surprisingly, the <CR><LF> EOLs are
>> still in the file in my working copy.
>>
>> 4) "svn propset svn:eol-style LF" that file in my working copy, verify
>> the property difference with "svn diff" and commit.  commit succeeds.
>>
>> 5) "svn cat" the file in the repo to see that, sure enough, the EOLs
>> have been reduced to simple <LF>s.  which is what i was after.
>>
>> 6) note, with some surprise, that the file in my working copy has
>> *also* been reduced to simple <LF> EOLs.  curious.  i would have
>> thought that i would have had to update first but i'm good with that.
>> so it looks like i can get the effect i want without having to resort
>> to hook scripts.
>>
>>  does all of that make sense?
>
> For files on which you set the svn:eol-style property (to any value),
> Subversion will convert their line endings to LF for storage in the
> repository. When bringing the file into a working copy, it will translate
> the line endings from LF to whatever the svn:eol-style property says to do,
> and on commit, it will convert back to LF.
>
> Users who change the line endings of a file with the svn:eol-style property
> wholly to another line ending style will have no problem; Subversion will
> convert it back to LF and accept the commit.
>
> Users who change the line endings of a file with the svn:eol-style property
> partially to another line ending style (e.g. some lines ending with LF, some
> ending with CRLF; some fantastic Windows editors like to do this) will
> encounter an error message from Subversion telling them the file has
> inconsistent line endings; the user must resolve this problem before
> committing.
>
> Users can change the line ending style of files that do not have the
> svn:eol-style property, either wholly or partially, and Subversion will
> accept the bytes they send with no complaint. This is why you should set up
> a pre-commit hook: to prevent people from committing new files that do not
> have the property set.
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
> For additional commands, e-mail: users-help_at_subversion.tigris.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-11-25 21:24:19 CET

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.