diff: demote core.safecrlf=true to core.safecrlf=warn
Otherwise the user will not be able to start to guess where in the contents in the working tree the offending unsafe CR lies. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jun 24, 2013 at 14:35 UTC
5430bb283b478991a979437a79e10dcbb6f20e28
2 files changed
+17
-1
diff.c
+9
-1
@@ -2647,6 +2647,14 @@ static int diff_populate_gitlink(struct diff_filespec *s, int size_only)
2647
int diff_populate_filespec(struct diff_filespec *s, int size_only)
2648
{
2649
int err = 0;
2650
+ /*
2651
+ * demote FAIL to WARN to allow inspecting the situation
2652
+ * instead of refusing.
2653
+ */
2654
+ enum safe_crlf crlf_warn = (safe_crlf == SAFE_CRLF_FAIL
2655
+ ? SAFE_CRLF_WARN
2656
+ : safe_crlf);
2657
+
2658
if (!DIFF_FILE_VALID(s))
2659
die("internal error: asking to populate invalid file.");
2660
if (S_ISDIR(s->mode))
@@ -2702,7 +2710,7 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
2710
/*
2711
* Convert from working tree format to canonical git format
2712
*/
2705
- if (convert_to_git(s->path, s->data, s->size, &buf, safe_crlf)) {
2713
+ if (convert_to_git(s->path, s->data, s->size, &buf, crlf_warn)) {
2714
size_t size = 0;
2715
munmap(s->data, s->size);
2716
s->should_munmap = 0;
t/t0020-crlf.sh
+8
@@ -81,6 +81,14 @@ test_expect_success 'safecrlf: print warning only once' '
81
test $(git add doublewarn 2>&1 | grep "CRLF will be replaced by LF" | wc -l) = 1
82
'
83
84
+
85
+test_expect_success 'safecrlf: git diff demotes safecrlf=true to warn' '
86
+ git config core.autocrlf input &&
87
+ git config core.safecrlf true &&
88
+ git diff HEAD
89
+'
90
+
91
+
92
test_expect_success 'switch off autocrlf, safecrlf, reset HEAD' '
93
git config core.autocrlf false &&
94
git config core.safecrlf false &&