Re: CRLF problems with Git on Win32

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Jan 8, 2008, at 8:09 PM, J. Bruce Fields wrote:

On Tue, Jan 08, 2008 at 07:58:57PM +0100, Steffen Prohaska wrote:

On Jan 8, 2008, at 7:07 PM, Junio C Hamano wrote:



Steffen Prohaska <prohaska-wjoc1KHpMeg@xxxxxxxxxxxxxxxx> writes:

msysgit installs plain git. core.autocrlf is unset. Whatever plain
git's default is, this is msysgit's default, too.

That sounds like a mistake if you are installing a port to a
platform whose native line ending convention is different from
where plain git natively runs on (i.e. UNIX).

We failed to agree on a better default and as the lengthy
discussion documents, the best default isn't obvious.

I don't think a solution will be found by declaring one platform
native (UNIX) and all other platform non-native.  The question to
answer is how to support cross-platform projects.  A valid
solution should never corrupt data unless the user explicitly
told git to do so.

My only suggestion is that we consider allowing the user that
"explicitly told git to do so" be the project maintainer.  So if you

	echo * autodetectcrlf >.gitattributes
	git add .gitattributes
	git commit

then users that clone your repo will get that default without having to
be told to do something magic on clone.

(And ideally I'd've hoped you could do that using the existing crlf
attribute rather than having to invent something new, but maybe that
doesn't work.)

I like this idea.

I think we need the following:
 - if "autodetectcrlf" is set, git should guarantee that files in
   the repository will always have LF-only.  Otherwise the automatic
   conversion can't work.
 - git needs to support a way to select the preferred type of
   line endings based on the OS.  Unix users want to see LF,
   while Windows users want to see CRLF for the same file.

And we could implement it as follows:
 - We add a configuration variable that sets the preferred
   autocrlf conversion, for example core.defaultautocrlf.
 - We add a new string value "defaultauto" for crlf in .gitattributes.
   crlf=defaultauto is similar to setting crlf to "Unspecified", but
   also forces git to act as if core.autocrlf is set to
   $(core.defaultautocrlf).  That means if the content looks like text
   it will be converted according to the local settings.
 - On Unix, core.defaultautocrlf defaults to "input".
 - On Windows, core.defaultautocrlf defaults to "crlf".

This added layer of indirection gives us what we need:  The
file .gitattributes tells git to convert line endings; but the
details of the conversion depend on the environment (OS or
configuration).

	Steffen

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux