summaryrefslogtreecommitdiff
path: root/convert.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-09-10 08:02:55 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-09-10 08:02:55 (GMT)
commit648a50a08ad3d6718899a30a438ff97b4bdda342 (patch)
treebdae2506cdf6e746359bd14473c86b16b7d67165 /convert.c
parent27015b4f95cddd51172a8b12a05fd68f4477bdfb (diff)
parentc24f3abaceabb590125751a67ec0e32946780ac7 (diff)
downloadgit-648a50a08ad3d6718899a30a438ff97b4bdda342.zip
git-648a50a08ad3d6718899a30a438ff97b4bdda342.tar.gz
git-648a50a08ad3d6718899a30a438ff97b4bdda342.tar.bz2
Merge branch 'tb/apply-with-crlf' into maint
"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
Diffstat (limited to 'convert.c')
-rw-r--r--convert.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/convert.c b/convert.c
index 4936fcc..387c1c5 100644
--- a/convert.c
+++ b/convert.c
@@ -1133,10 +1133,12 @@ int convert_to_git(const struct index_state *istate,
src = dst->buf;
len = dst->len;
}
- ret |= crlf_to_git(istate, path, src, len, dst, ca.crlf_action, checksafe);
- if (ret && dst) {
- src = dst->buf;
- len = dst->len;
+ if (checksafe != SAFE_CRLF_KEEP_CRLF) {
+ ret |= crlf_to_git(istate, path, src, len, dst, ca.crlf_action, checksafe);
+ if (ret && dst) {
+ src = dst->buf;
+ len = dst->len;
+ }
}
return ret | ident_to_git(path, src, len, dst, ca.ident);
}