summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 913e0e9)
raw | patch | inline | side by side (parent: 913e0e9)
author | Alexander Gavrilov <angavrilov@gmail.com> | |
Sat, 23 Aug 2008 19:21:21 +0000 (23:21 +0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 24 Aug 2008 06:59:20 +0000 (23:59 -0700) |
Fix git-diff to make it produce useful 3-way diffs for merge conflicts in
repositories with autocrlf enabled. Otherwise it always reports that the
whole file was changed, because it uses the contents from the working tree
without necessary conversion.
Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
repositories with autocrlf enabled. Otherwise it always reports that the
whole file was changed, because it uses the contents from the working tree
without necessary conversion.
Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
combine-diff.c | patch | blob | history | |
t/t4015-diff-whitespace.sh | patch | blob | history |
diff --git a/combine-diff.c b/combine-diff.c
index 9f80a1c5e3a461afd11966625589684d61187911..4dfc33086755e7ae03310baabd0060149f323f4c 100644 (file)
--- a/combine-diff.c
+++ b/combine-diff.c
die("early EOF '%s'", elem->path);
result[len] = 0;
+
+ /* If not a fake symlink, apply filters, e.g. autocrlf */
+ if (is_file) {
+ struct strbuf buf;
+
+ strbuf_init(&buf, 0);
+ if (convert_to_git(elem->path, result, len, &buf, safe_crlf)) {
+ free(result);
+ result = strbuf_detach(&buf, &len);
+ result_size = len;
+ }
+ }
}
else {
deleted_file:
index ec98509fd2144121e599edd6a85217840041f321..b1cbd36d1710a38b94838a2fdf08e0e5ded431f8 100755 (executable)
git diff --check
'
+test_expect_success 'combined diff with autocrlf conversion' '
+
+ git reset --hard &&
+ echo >x hello &&
+ git commit -m "one side" x &&
+ git checkout HEAD^ &&
+ echo >x goodbye &&
+ git commit -m "the other side" x &&
+ git config core.autocrlf true &&
+ test_must_fail git merge master &&
+
+ git diff | sed -e "1,/^@@@/d" >actual &&
+ ! grep "^-" actual
+
+'
+
test_done