summaryrefslogtreecommitdiff
path: root/t/t6038-merge-text-auto.sh
diff options
context:
space:
mode:
authorEyvind Bernhardsen <eyvind.bernhardsen@gmail.com>2010-07-02 19:20:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-07-02 22:43:15 (GMT)
commitf217f0e86dc7bacc5dc127982eaadca758b558ce (patch)
treeffd4e74f1b5fb99e6434351354487f2d08c039f3 /t/t6038-merge-text-auto.sh
parent492b10766f499b60bdc867c253f36d274ac51538 (diff)
downloadgit-f217f0e86dc7bacc5dc127982eaadca758b558ce.zip
git-f217f0e86dc7bacc5dc127982eaadca758b558ce.tar.gz
git-f217f0e86dc7bacc5dc127982eaadca758b558ce.tar.bz2
Avoid conflicts when merging branches with mixed normalization
Currently, merging across changes in line ending normalization is painful since files containing CRLF will conflict with normalized files, even if the only difference between the two versions is the line endings. Additionally, any "real" merge conflicts that exist are obscured because every line in the file has a conflict. Assume you start out with a repo that has a lot of text files with CRLF checked in (A): o---C / \ A---B---D B: Add "* text=auto" to .gitattributes and normalize all files to LF-only C: Modify some of the text files D: Try to merge C You will get a ridiculous number of LF/CRLF conflicts when trying to merge C into D, since the repository contents for C are "wrong" wrt the new .gitattributes file. Fix ll-merge so that the "base", "theirs" and "ours" stages are passed through convert_to_worktree() and convert_to_git() before a three-way merge. This ensures that all three stages are normalized in the same way, removing from consideration differences that are only due to normalization. This feature is optional for now since it changes a low-level mechanism and is not necessary for the majority of users. The "merge.renormalize" config variable enables it. Signed-off-by: Eyvind Bernhardsen <eyvind.bernhardsen@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t6038-merge-text-auto.sh')
-rwxr-xr-xt/t6038-merge-text-auto.sh64
1 files changed, 64 insertions, 0 deletions
diff --git a/t/t6038-merge-text-auto.sh b/t/t6038-merge-text-auto.sh
new file mode 100755
index 0000000..127baf8
--- /dev/null
+++ b/t/t6038-merge-text-auto.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+test_description='CRLF merge conflict across text=auto change'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ git config merge.renormalize true &&
+ git config core.autocrlf false &&
+ echo first line | append_cr >file &&
+ echo first line >control_file &&
+ echo only line >inert_file &&
+ git add file control_file inert_file &&
+ git commit -m "Initial" &&
+ git tag initial &&
+ git branch side &&
+ echo "* text=auto" >.gitattributes &&
+ touch file &&
+ git add .gitattributes file &&
+ git commit -m "normalize file" &&
+ echo same line | append_cr >>file &&
+ echo same line >>control_file &&
+ git add file control_file &&
+ git commit -m "add line from a" &&
+ git tag a &&
+ git rm .gitattributes &&
+ rm file &&
+ git checkout file &&
+ git commit -m "remove .gitattributes" &&
+ git tag c &&
+ git checkout side &&
+ echo same line | append_cr >>file &&
+ echo same line >>control_file &&
+ git add file control_file &&
+ git commit -m "add line from b" &&
+ git tag b &&
+ git checkout master
+'
+
+test_expect_success 'Check merging after setting text=auto' '
+ git reset --hard a &&
+ git merge b &&
+ cat file | remove_cr >file.temp &&
+ test_cmp file file.temp
+'
+
+test_expect_success 'Check merging addition of text=auto' '
+ git reset --hard b &&
+ git merge a &&
+ cat file | remove_cr >file.temp &&
+ test_cmp file file.temp
+'
+
+test_expect_failure 'Test delete/normalize conflict' '
+ git checkout side &&
+ git reset --hard initial &&
+ git rm file &&
+ git commit -m "remove file" &&
+ git checkout master &&
+ git reset --hard a^ &&
+ git merge side
+'
+
+test_done