Subject: Re: CRLF problems with Git on Win32

From: Gregory Jefferis <[email-masked]>
Date: Wed, 09 Jan 2008 17:37:07 +0000

On 9/1/08 15:03, "Dmitry Potapov" <[email-masked]> wrote:

> On Wed, Jan 09, 2008 at 01:52:59PM +0000, Gregory Jefferis wrote:
>> 
>> Re point (1) to be reversible in practice, we need to know who we've munged.
>> Otherwise when gnuming blindly at checkout we might damage some innocent
>> bystander file that only ever had LFs in the first place.
> 
> If you work on Windows and you have clrf=safe, you cannot put a text
> file that has only LFs, because naked LF is not allowed. If you want
> to have naked LF in some file, you have to say that explicitly in
> .gitattributes.
> 
> If you work on cross platform project, and somebody else put a file with
> bare LFs, which is not text though heauristic wrongly detected it as
> text then you can remove this file from your working directory, correct
> .gitattributes and checkout this file again. The idea of crlf=safe is
> that information is never lost. It is always fully reversible, and if
> you put something into the repostory, you always get back exactly the
> same unless you changed your .gitattributes.
> 
>> Re (2) well if we happen to munge a file on checkin that is actually binary,
>> it must be gnumed on the way out otherwise it will be broken for the user.
> 
> Of course, it will, because the same heuristic will detect it as text,
> and convert it back. So as long as you stay on the same platform and
> with the same .gitattributes, you always get back exactly what you
> put.

Dmitry, I think all of your comments are correct, BUT, this behaviour as
currently proposed still does not seem to me safe (or perhaps transparent)
enough to be enabled by default on a Windows platform (or for that matter a
Unix one).

If LF text files checked in on Windows get turned into CRLF files on
checkout by default then I think plenty of people would be surprised and
probably unhappy.  Similarly I think it would be a bad thing if a binary
file that looked like LF only text got mangled on checkout by LF->CRLF
conversion - although I agree that it would be possible to recover from this
situation with a bit of juggling.

So my view is still that this behaviour would be a useful option when
explicitly enabled by .gitattributes (as opposed to the current auto CRLF
implementation, which could lead to irreversible munging) but that it is not
an appropriate system-wide default.  I could however see that sane people
might disagree! 

For that matter autocrlf=true,input,safe are all slightly dubious when used
as config vars rather than as attributes for the same collateral damage
reason discussed above.  The only way to prevent collateral damage is to
consult .gitattributes on checkout (as Dmitry seemed to be assuming above)
rather than gnuming anything in the repository that looked like LF only
text.  Of course even .gitattributes can change over time, so only by
storing a "munged" metadata attribute in the repository could you guarantee
that everything came out as it went in - which I think is a highly desirable
base state.  

Greg.