Re: git diff returns fatal error with core.safecrlf is set to true.

Subsystems: the rest

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: git diff returns fatal error with core.safecrlf is set to true.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:52

Junio C Hamano [off-list ref] writes:
The helper may want to learn a way to be told to demote that error
to a warning.
Perhaps something like this?

 diff.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/diff.c b/diff.c
index f0b3e7c..9b4f3ac 100644
--- a/diff.c
+++ b/diff.c
@@ -2677,6 +2677,10 @@ static int diff_populate_gitlink(struct diff_filespec *s, int size_only)
 int diff_populate_filespec(struct diff_filespec *s, int size_only)
 {
 	int err = 0;
+	enum safe_crlf crlf_warn = (safe_crlf != SAFE_CRLF_FAIL
+				    ? safe_crlf
+				    : SAFE_CRLF_WARN);
+
 	if (!DIFF_FILE_VALID(s))
 		die("internal error: asking to populate invalid file.");
 	if (S_ISDIR(s->mode))
@@ -2732,7 +2736,7 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
 		/*
 		 * Convert from working tree format to canonical git format
 		 */
-		if (convert_to_git(s->path, s->data, s->size, &buf, safe_crlf)) {
+		if (convert_to_git(s->path, s->data, s->size, &buf, crlf_warn)) {
 			size_t size = 0;
 			munmap(s->data, s->size);
 			s->should_munmap = 0;

Re: git diff returns fatal error with core.safecrlf is set to true.

From: Yann Droneaud <hidden>
Date: 2016-06-15 22:57:53

Hi,

Le 21.06.2013 23:57, Junio C Hamano a écrit :
Junio C Hamano [off-list ref] writes:
quoted
The helper may want to learn a way to be told to demote that error
to a warning.
Perhaps something like this?
Thanks for the patch.

I run my test again, eg. run git diff after a rebase failure (see my 
other mail about core.safecrlf),
I'm able to run git diff a get a meaningful output:

# git version 1.8.1.4
fatal: CRLF would be replaced by LF in test.

# git version 1.8.3.1.741.g635527f.dirty (eg. next + your patch)
warning: CRLF will be replaced by LF in test.
The file will have its original line endings in your working directory.
diff --git a/test b/test
index b043836..63ba10f 100644
--- a/test
+++ b/test
@@ -1,4 +1,4 @@
-Hello World 1
-Hello World 2
-Hello World 3
+Hello World 1
+Hello World 2
+Hello World 3
  Hello World 4
\ No newline at end of file

It seems better. The removed lines have CRLF EOL while the added line 
have LF line ending characters.

Tested-By: Yann Droneaud <redacted>


Regards.

-- 
Yann Droneaud
OPTEYA
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help