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 if test_have_prereq NATIVE_CRLF; then
76 append_cr <expected >expected.temp &&
77 mv expected.temp expected
79 git config merge.renormalize true &&
81 rm -f .gitattributes &&
84 test_cmp expected file
87 test_expect_success
'Merge addition of text=auto' '
88 cat <<-\EOF >expected &&
93 if test_have_prereq NATIVE_CRLF; then
94 append_cr <expected >expected.temp &&
95 mv expected.temp expected
97 git config merge.renormalize true &&
99 rm -f .gitattributes &&
100 git reset --hard b &&
102 test_cmp expected file
105 test_expect_success
'Detect CRLF/LF conflict after setting text=auto' '
106 echo "<<<<<<<" >expected &&
107 if test_have_prereq NATIVE_CRLF; then
108 echo first line | append_cr >>expected &&
109 echo same line | append_cr >>expected &&
110 echo ======= | append_cr >>expected
112 echo first line >>expected &&
113 echo same line >>expected &&
114 echo ======= >>expected
116 echo first line | append_cr >>expected &&
117 echo same line | append_cr >>expected &&
118 echo ">>>>>>>" >>expected &&
119 git config merge.renormalize false &&
120 rm -f .gitattributes &&
121 git reset --hard a &&
122 test_must_fail git merge b &&
123 fuzz_conflict file >file.fuzzy &&
124 test_cmp expected file.fuzzy
127 test_expect_success
'Detect LF/CRLF conflict from addition of text=auto' '
128 echo "<<<<<<<" >expected &&
129 echo first line | append_cr >>expected &&
130 echo same line | append_cr >>expected &&
131 if test_have_prereq NATIVE_CRLF; then
132 echo ======= | append_cr >>expected &&
133 echo first line | append_cr >>expected &&
134 echo same line | append_cr >>expected
136 echo ======= >>expected &&
137 echo first line >>expected &&
138 echo same line >>expected
140 echo ">>>>>>>" >>expected &&
141 git config merge.renormalize false &&
142 rm -f .gitattributes &&
143 git reset --hard b &&
144 test_must_fail git merge a &&
145 fuzz_conflict file >file.fuzzy &&
146 test_cmp expected file.fuzzy
149 test_expect_failure
'checkout -m after setting text=auto' '
150 cat <<-\EOF >expected &&
155 git config merge.renormalize true &&
157 rm -f .gitattributes &&
158 git reset --hard initial &&
159 git checkout a -- . &&
161 test_cmp expected file
164 test_expect_failure
'checkout -m addition of text=auto' '
165 cat <<-\EOF >expected &&
170 git config merge.renormalize true &&
172 rm -f .gitattributes file &&
173 git reset --hard initial &&
174 git checkout b -- . &&
176 test_cmp expected file
179 test_expect_failure
'cherry-pick patch from after text=auto was added' '
180 append_cr <<-\EOF >expected &&
185 git config merge.renormalize true &&
187 git reset --hard b &&
188 test_must_fail git cherry-pick a >err 2>&1 &&
189 grep "[Nn]othing added" err &&
190 test_cmp expected file
193 test_expect_success
'Test delete/normalize conflict' '
194 git checkout -f side &&
196 rm -f .gitattributes &&
197 git reset --hard initial &&
199 git commit -m "remove file" &&
200 git checkout master &&
201 git reset --hard a^ &&