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>
This commit is contained in:
parent
7e2010537e
commit
5430bb283b
10
diff.c
10
diff.c
@ -2647,6 +2647,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 diff_populate_filespec(struct diff_filespec *s, int size_only)
|
||||||
{
|
{
|
||||||
int err = 0;
|
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))
|
if (!DIFF_FILE_VALID(s))
|
||||||
die("internal error: asking to populate invalid file.");
|
die("internal error: asking to populate invalid file.");
|
||||||
if (S_ISDIR(s->mode))
|
if (S_ISDIR(s->mode))
|
||||||
@ -2702,7 +2710,7 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
|
|||||||
/*
|
/*
|
||||||
* Convert from working tree format to canonical git format
|
* 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;
|
size_t size = 0;
|
||||||
munmap(s->data, s->size);
|
munmap(s->data, s->size);
|
||||||
s->should_munmap = 0;
|
s->should_munmap = 0;
|
||||||
|
@ -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 $(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' '
|
test_expect_success 'switch off autocrlf, safecrlf, reset HEAD' '
|
||||||
git config core.autocrlf false &&
|
git config core.autocrlf false &&
|
||||||
git config core.safecrlf false &&
|
git config core.safecrlf false &&
|
||||||
|
Loading…
Reference in New Issue
Block a user