"git apply" that is used as a better "patch -p1" failed to apply a
taken from a file with CRLF line endings to a file with CRLF line
endings. The root cause was because it misused convert_to_git()
that tried to do "safe-crlf" processing by looking at the index
entry at the same path, which is a nonsense---in that mode, "apply"
is not working on the data in (or derived from) the index at all.
This has been fixed.
* tb/apply-with-crlf:
apply: file commited with CRLF should roundtrip diff and apply
convert: add SAFE_CRLF_KEEP_CRLF
@ -467,21 +467,42 @@ test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '
@@ -467,21 +467,42 @@ test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '
test_cmp one expect
'
test_expect_success 'same, but with CR-LF line endings && cr-at-eol unset' '
test_expect_success 'CR-LF line endings && add line && text=auto' '
git config --unset core.whitespace &&
printf "a\r\n" >one &&
cp one save-one &&
git add one &&
printf "b\r\n" >>one &&
printf "c\r\n" >>one &&
cp one expect &&
git diff -- one >patch &&
mv save-one one &&
echo "one text=auto" >.gitattributes &&
git apply patch &&
test_cmp one expect
'
test_expect_success 'CR-LF line endings && change line && text=auto' '