Re: CRLF problems with Git on Win32

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

 



Dmitry Potapov <dpotapov@xxxxxxxxx> writes:

> On Tue, Jan 08, 2008 at 07:58:57PM +0100, Steffen Prohaska wrote:
>> 
>> 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.  I don't believe it is a valid solution to set
>> core.autocrlf=true on Windows and tell the users: "Well, in its
>> default settings, git sometimes corrupts your data on Windows.
>> Maybe you want to switch to Linux because this is the native
>> platform where data corruption will never happen."
>
> Maybe I am wrong but it seems to me that to guarantee that
> CRLF conversion is reversible (which means that you can
> always get exactly what you put into the repository), it is
> enough to check that the conversation is performed only if
> every LF is preceded by CR.

I've heard that before but I seem to recall convert.c already
doing something similar if I am not mistaken.

static int crlf_to_git(const char *path, const char *src, size_t len,
                       struct strbuf *buf, int action)
{
	struct text_stat stats;
	char *dst;

	if ((action == CRLF_BINARY) || !auto_crlf || !len)
		return 0;

	gather_stats(src, len, &stats);
	/* No CR? Nothing to convert, regardless. */
	if (!stats.cr)
		return 0;

	if (action == CRLF_GUESS) {
		/*
		 * We're currently not going to even try to convert stuff
		 * that has bare CR characters. Does anybody do that crazy
		 * stuff?
		 */
		if (stats.cr != stats.crlf)
			return 0;

		/*
		 * And add some heuristics for binary vs text, of course...
		 */
		if (is_binary(len, &stats))
			return 0;
	}

It counts CR and CRLF and converts only when there are the same
number of them.  You probably only need to make it also count
LF?
-
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