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
20 tr '\015\000' QN <"$1" >"$1".expect &&
21 tr '\015\000' QN <"$2" >"$2".actual &&
22 test_cmp "$1".expect "$2".actual &&
23 rm "$1".expect "$2".actual
26 test_expect_success setup '
27 git config core.autocrlf false &&
29 echo first line | append_cr >file &&
30 echo first line >control_file &&
31 echo only line >inert_file &&
33 git add file control_file inert_file &&
35 git commit -m "Initial" &&
39 echo "* text=auto" >.gitattributes &&
40 echo first line >file &&
41 git add .gitattributes file &&
43 git commit -m "normalize file" &&
45 echo same line | append_cr >>file &&
46 echo same line >>control_file &&
47 git add file control_file &&
49 git commit -m "add line from a" &&
52 git rm .gitattributes &&
56 git commit -m "remove .gitattributes" &&
60 echo same line | append_cr >>file &&
61 echo same line >>control_file &&
62 git add file control_file &&
64 git commit -m "add line from b" &&
70 test_expect_success 'set up fuzz_conflict() helper' '
72 sed $SED_OPTIONS -e "s/^\([<>=]......\) .*/\1/" "$@"
76 test_expect_success 'Merge after setting text=auto' '
77 cat <<-\EOF >expected &&
82 if test_have_prereq NATIVE_CRLF; then
83 append_cr <expected >expected.temp &&
84 mv expected.temp expected
86 git config merge.renormalize true &&
88 rm -f .gitattributes &&
91 compare_files expected file
94 test_expect_success 'Merge addition of text=auto' '
95 cat <<-\EOF >expected &&
100 if test_have_prereq NATIVE_CRLF; then
101 append_cr <expected >expected.temp &&
102 mv expected.temp expected
104 git config merge.renormalize true &&
106 rm -f .gitattributes &&
107 git reset --hard b &&
109 compare_files expected file
112 test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
113 echo "<<<<<<<" >expected &&
114 if test_have_prereq NATIVE_CRLF; then
115 echo first line | append_cr >>expected &&
116 echo same line | append_cr >>expected &&
117 echo ======= | append_cr >>expected
119 echo first line >>expected &&
120 echo same line >>expected &&
121 echo ======= >>expected
123 echo first line | append_cr >>expected &&
124 echo same line | append_cr >>expected &&
125 echo ">>>>>>>" >>expected &&
126 git config merge.renormalize false &&
127 rm -f .gitattributes &&
128 git reset --hard a &&
129 test_must_fail git merge b &&
130 fuzz_conflict file >file.fuzzy &&
131 compare_files expected file.fuzzy
134 test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' '
135 echo "<<<<<<<" >expected &&
136 echo first line | append_cr >>expected &&
137 echo same line | append_cr >>expected &&
138 if test_have_prereq NATIVE_CRLF; then
139 echo ======= | append_cr >>expected &&
140 echo first line | append_cr >>expected &&
141 echo same line | append_cr >>expected
143 echo ======= >>expected &&
144 echo first line >>expected &&
145 echo same line >>expected
147 echo ">>>>>>>" >>expected &&
148 git config merge.renormalize false &&
149 rm -f .gitattributes &&
150 git reset --hard b &&
151 test_must_fail git merge a &&
152 fuzz_conflict file >file.fuzzy &&
153 compare_files expected file.fuzzy
156 test_expect_failure 'checkout -m after setting text=auto' '
157 cat <<-\EOF >expected &&
162 git config merge.renormalize true &&
164 rm -f .gitattributes &&
165 git reset --hard initial &&
166 git checkout a -- . &&
168 compare_files expected file
171 test_expect_failure 'checkout -m addition of text=auto' '
172 cat <<-\EOF >expected &&
177 git config merge.renormalize true &&
179 rm -f .gitattributes file &&
180 git reset --hard initial &&
181 git checkout b -- . &&
183 compare_files expected file
186 test_expect_failure 'cherry-pick patch from after text=auto was added' '
187 append_cr <<-\EOF >expected &&
192 git config merge.renormalize true &&
194 git reset --hard b &&
195 test_must_fail git cherry-pick a >err 2>&1 &&
196 grep "[Nn]othing added" err &&
197 compare_files expected file
200 test_expect_success 'Test delete/normalize conflict' '
201 git checkout -f side &&
203 rm -f .gitattributes &&
204 git reset --hard initial &&
206 git commit -m "remove file" &&
207 git checkout master &&
208 git reset --hard a^ &&