3 test_description='CRLF merge conflict across text=auto change
5 * [master] remove .gitattributes
6 ! [side] add line from b
8 + [side] add line from b
9 * [master] remove .gitattributes
10 * [master^] add line from a
11 * [master~2] normalize file
17 test_expect_success setup '
18 git config core.autocrlf false &&
20 echo first line | append_cr >file &&
21 echo first line >control_file &&
22 echo only line >inert_file &&
24 git add file control_file inert_file &&
26 git commit -m "Initial" &&
30 echo "* text=auto" >.gitattributes &&
32 git add .gitattributes file &&
34 git commit -m "normalize file" &&
36 echo same line | append_cr >>file &&
37 echo same line >>control_file &&
38 git add file control_file &&
40 git commit -m "add line from a" &&
43 git rm .gitattributes &&
47 git commit -m "remove .gitattributes" &&
51 echo same line | append_cr >>file &&
52 echo same line >>control_file &&
53 git add file control_file &&
55 git commit -m "add line from b" &&
61 test_expect_success 'set up fuzz_conflict() helper' '
63 sed -e "s/^\([<>=]......\) .*/\1/" "$@"
67 test_expect_success 'Merge after setting text=auto' '
68 cat <<-\EOF >expected &&
73 git config merge.renormalize true &&
75 rm -f .gitattributes &&
78 test_cmp expected file
81 test_expect_success 'Merge addition of text=auto' '
82 cat <<-\EOF >expected &&
87 git config merge.renormalize true &&
89 rm -f .gitattributes &&
92 test_cmp expected file
95 test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
96 q_to_cr <<-\EOF >expected &&
106 git config merge.renormalize false &&
107 rm -f .gitattributes &&
108 git reset --hard a &&
109 test_must_fail git merge b &&
110 fuzz_conflict file >file.fuzzy &&
111 test_cmp expected file.fuzzy
114 test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' '
115 q_to_cr <<-\EOF >expected &&
125 git config merge.renormalize false &&
126 rm -f .gitattributes &&
127 git reset --hard b &&
128 test_must_fail git merge a &&
129 fuzz_conflict file >file.fuzzy &&
130 test_cmp expected file.fuzzy
133 test_expect_failure 'checkout -m after setting text=auto' '
134 cat <<-\EOF >expected &&
139 git config merge.renormalize true &&
141 rm -f .gitattributes &&
142 git reset --hard initial &&
143 git checkout a -- . &&
145 test_cmp expected file
148 test_expect_failure 'checkout -m addition of text=auto' '
149 cat <<-\EOF >expected &&
154 git config merge.renormalize true &&
156 rm -f .gitattributes file &&
157 git reset --hard initial &&
158 git checkout b -- . &&
160 test_cmp expected file
163 test_expect_failure 'cherry-pick patch from after text=auto was added' '
164 append_cr <<-\EOF >expected &&
169 git config merge.renormalize true &&
171 git reset --hard b &&
172 test_must_fail git cherry-pick a >err 2>&1 &&
173 grep "[Nn]othing added" err &&
174 test_cmp expected file
177 test_expect_success 'Test delete/normalize conflict' '
178 git checkout -f side &&
180 rm -f .gitattributes &&
181 git reset --hard initial &&
183 git commit -m "remove file" &&
184 git checkout master &&
185 git reset --hard a^ &&