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 eol=LF' '
95 git config core.eol lf &&
96 cat <<-\EOF >expected &&
101 git config merge.renormalize true &&
103 rm -f .gitattributes &&
104 git reset --hard b &&
106 compare_files expected file
109 test_expect_success 'Merge addition of text=auto eol=CRLF' '
110 git config core.eol crlf &&
111 cat <<-\EOF >expected &&
116 append_cr <expected >expected.temp &&
117 mv expected.temp expected &&
118 git config merge.renormalize true &&
120 rm -f .gitattributes &&
121 git reset --hard b &&
122 echo >&2 "After git reset --hard b" &&
123 git ls-files -s --eol >&2 &&
125 compare_files expected file
128 test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
129 git config core.eol native &&
130 echo "<<<<<<<" >expected &&
131 echo first line >>expected &&
132 echo same line >>expected &&
133 echo ======= >>expected &&
134 echo first line | append_cr >>expected &&
135 echo same line | append_cr >>expected &&
136 echo ">>>>>>>" >>expected &&
137 git config merge.renormalize false &&
138 rm -f .gitattributes &&
139 git reset --hard a &&
140 test_must_fail git merge b &&
141 fuzz_conflict file >file.fuzzy &&
142 compare_files expected file.fuzzy
145 test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' '
146 echo "<<<<<<<" >expected &&
147 echo first line | append_cr >>expected &&
148 echo same line | append_cr >>expected &&
149 echo ======= >>expected &&
150 echo first line >>expected &&
151 echo same line >>expected &&
152 echo ">>>>>>>" >>expected &&
153 git config merge.renormalize false &&
154 rm -f .gitattributes &&
155 git reset --hard b &&
156 test_must_fail git merge a &&
157 fuzz_conflict file >file.fuzzy &&
158 compare_files expected file.fuzzy
161 test_expect_success 'checkout -m after setting text=auto' '
162 cat <<-\EOF >expected &&
167 git config merge.renormalize true &&
169 rm -f .gitattributes &&
170 git reset --hard initial &&
171 git restore --source=a -- . &&
173 git diff --no-index --ignore-cr-at-eol expected file
176 test_expect_success 'checkout -m addition of text=auto' '
177 cat <<-\EOF >expected &&
182 git config merge.renormalize true &&
184 rm -f .gitattributes file &&
185 git reset --hard initial &&
186 git restore --source=b -- . &&
188 git diff --no-index --ignore-cr-at-eol expected file
191 test_expect_success 'Test delete/normalize conflict' '
192 git checkout -f side &&
194 rm -f .gitattributes &&
195 git reset --hard initial &&
197 git commit -m "remove file" &&
198 git checkout master &&
199 git reset --hard a^ &&
201 test_path_is_missing file