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_have_prereq SED_STRIPS_CR && SED_OPTIONS=-b
19 test_expect_success setup '
20 git config core.autocrlf false &&
22 echo first line | append_cr >file &&
23 echo first line >control_file &&
24 echo only line >inert_file &&
26 git add file control_file inert_file &&
28 git commit -m "Initial" &&
32 echo "* text=auto" >.gitattributes &&
34 git add .gitattributes file &&
36 git commit -m "normalize file" &&
38 echo same line | append_cr >>file &&
39 echo same line >>control_file &&
40 git add file control_file &&
42 git commit -m "add line from a" &&
45 git rm .gitattributes &&
49 git commit -m "remove .gitattributes" &&
53 echo same line | append_cr >>file &&
54 echo same line >>control_file &&
55 git add file control_file &&
57 git commit -m "add line from b" &&
63 test_expect_success 'set up fuzz_conflict() helper' '
65 sed $SED_OPTIONS -e "s/^\([<>=]......\) .*/\1/" "$@"
69 test_expect_success 'Merge after setting text=auto' '
70 cat <<-\EOF >expected &&
75 git config merge.renormalize true &&
77 rm -f .gitattributes &&
80 test_cmp expected file
83 test_expect_success 'Merge addition of text=auto' '
84 cat <<-\EOF >expected &&
89 git config merge.renormalize true &&
91 rm -f .gitattributes &&
94 test_cmp expected file
97 test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
98 q_to_cr <<-\EOF >expected &&
108 git config merge.renormalize false &&
109 rm -f .gitattributes &&
110 git reset --hard a &&
111 test_must_fail git merge b &&
112 fuzz_conflict file >file.fuzzy &&
113 test_cmp expected file.fuzzy
116 test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' '
117 q_to_cr <<-\EOF >expected &&
127 git config merge.renormalize false &&
128 rm -f .gitattributes &&
129 git reset --hard b &&
130 test_must_fail git merge a &&
131 fuzz_conflict file >file.fuzzy &&
132 test_cmp expected file.fuzzy
135 test_expect_failure 'checkout -m after setting text=auto' '
136 cat <<-\EOF >expected &&
141 git config merge.renormalize true &&
143 rm -f .gitattributes &&
144 git reset --hard initial &&
145 git checkout a -- . &&
147 test_cmp expected file
150 test_expect_failure 'checkout -m addition of text=auto' '
151 cat <<-\EOF >expected &&
156 git config merge.renormalize true &&
158 rm -f .gitattributes file &&
159 git reset --hard initial &&
160 git checkout b -- . &&
162 test_cmp expected file
165 test_expect_failure 'cherry-pick patch from after text=auto was added' '
166 append_cr <<-\EOF >expected &&
171 git config merge.renormalize true &&
173 git reset --hard b &&
174 test_must_fail git cherry-pick a >err 2>&1 &&
175 grep "[Nn]othing added" err &&
176 test_cmp expected file
179 test_expect_success 'Test delete/normalize conflict' '
180 git checkout -f side &&
182 rm -f .gitattributes &&
183 git reset --hard initial &&
185 git commit -m "remove file" &&
186 git checkout master &&
187 git reset --hard a^ &&