diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-07-21 22:48:13 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-07-21 22:48:13 -0700 |
commit | 82ec54dc8bbb653faa64638d74129e45aea3326b (patch) | |
tree | d3ca5f57694f8551da4a8fec7feb0f6504e59b90 | |
parent | t9801: git-p4: check ignore files with client spec (diff) | |
parent | diff: demote core.safecrlf=true to core.safecrlf=warn (diff) | |
download | tgif-82ec54dc8bbb653faa64638d74129e45aea3326b.tar.xz |
Merge branch 'jc/maint-diff-core-safecrlf' into maint
Avoid failing "git diff" when core.safecrlf is set to true, because
the user cannot tell where the breakage is in preparation for fixing
and committing.
* jc/maint-diff-core-safecrlf:
diff: demote core.safecrlf=true to core.safecrlf=warn
-rw-r--r-- | diff.c | 10 | ||||
-rwxr-xr-x | t/t0020-crlf.sh | 8 |
2 files changed, 17 insertions, 1 deletions
@@ -2677,6 +2677,14 @@ 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; + /* + * demote FAIL to WARN to allow inspecting the situation + * instead of refusing. + */ + enum safe_crlf crlf_warn = (safe_crlf == SAFE_CRLF_FAIL + ? SAFE_CRLF_WARN + : safe_crlf); + if (!DIFF_FILE_VALID(s)) die("internal error: asking to populate invalid file."); if (S_ISDIR(s->mode)) @@ -2732,7 +2740,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; diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh index 1a8f44c44c..e526184a0b 100755 --- a/t/t0020-crlf.sh +++ b/t/t0020-crlf.sh @@ -81,6 +81,14 @@ test_expect_success 'safecrlf: print warning only once' ' test $(git add doublewarn 2>&1 | grep "CRLF will be replaced by LF" | wc -l) = 1 ' + +test_expect_success 'safecrlf: git diff demotes safecrlf=true to warn' ' + git config core.autocrlf input && + git config core.safecrlf true && + git diff HEAD +' + + test_expect_success 'switch off autocrlf, safecrlf, reset HEAD' ' git config core.autocrlf false && git config core.safecrlf false && |