]>
Commit | Line | Data |
---|---|---|
f217f0e8 EB |
1 | #!/bin/sh |
2 | ||
18acb30e JN |
3 | test_description='CRLF merge conflict across text=auto change |
4 | ||
5 | * [master] remove .gitattributes | |
6 | ! [side] add line from b | |
7 | -- | |
8 | + [side] add line from b | |
9 | * [master] remove .gitattributes | |
10 | * [master^] add line from a | |
11 | * [master~2] normalize file | |
12 | *+ [side^] Initial | |
13 | ' | |
f217f0e8 EB |
14 | |
15 | . ./test-lib.sh | |
16 | ||
a31d0665 | 17 | test_have_prereq SED_STRIPS_CR && SED_OPTIONS=-b |
ca02ad34 | 18 | |
f217f0e8 | 19 | test_expect_success setup ' |
f217f0e8 | 20 | git config core.autocrlf false && |
18acb30e | 21 | |
f217f0e8 EB |
22 | echo first line | append_cr >file && |
23 | echo first line >control_file && | |
24 | echo only line >inert_file && | |
18acb30e | 25 | |
f217f0e8 | 26 | git add file control_file inert_file && |
18acb30e | 27 | test_tick && |
f217f0e8 EB |
28 | git commit -m "Initial" && |
29 | git tag initial && | |
30 | git branch side && | |
18acb30e | 31 | |
f217f0e8 EB |
32 | echo "* text=auto" >.gitattributes && |
33 | touch file && | |
34 | git add .gitattributes file && | |
18acb30e | 35 | test_tick && |
f217f0e8 | 36 | git commit -m "normalize file" && |
18acb30e | 37 | |
f217f0e8 EB |
38 | echo same line | append_cr >>file && |
39 | echo same line >>control_file && | |
40 | git add file control_file && | |
18acb30e | 41 | test_tick && |
f217f0e8 EB |
42 | git commit -m "add line from a" && |
43 | git tag a && | |
18acb30e | 44 | |
f217f0e8 EB |
45 | git rm .gitattributes && |
46 | rm file && | |
47 | git checkout file && | |
18acb30e | 48 | test_tick && |
f217f0e8 EB |
49 | git commit -m "remove .gitattributes" && |
50 | git tag c && | |
18acb30e | 51 | |
f217f0e8 EB |
52 | git checkout side && |
53 | echo same line | append_cr >>file && | |
54 | echo same line >>control_file && | |
55 | git add file control_file && | |
18acb30e | 56 | test_tick && |
f217f0e8 EB |
57 | git commit -m "add line from b" && |
58 | git tag b && | |
18acb30e | 59 | |
f217f0e8 EB |
60 | git checkout master |
61 | ' | |
62 | ||
beeeb454 JN |
63 | test_expect_success 'set up fuzz_conflict() helper' ' |
64 | fuzz_conflict() { | |
ca02ad34 | 65 | sed $SED_OPTIONS -e "s/^\([<>=]......\) .*/\1/" "$@" |
beeeb454 JN |
66 | } |
67 | ' | |
68 | ||
18acb30e JN |
69 | test_expect_success 'Merge after setting text=auto' ' |
70 | cat <<-\EOF >expected && | |
71 | first line | |
72 | same line | |
73 | EOF | |
74 | ||
5f4e02e5 BL |
75 | if test_have_prereq NATIVE_CRLF; then |
76 | append_cr <expected >expected.temp && | |
77 | mv expected.temp expected | |
78 | fi && | |
beeeb454 | 79 | git config merge.renormalize true && |
18acb30e JN |
80 | git rm -fr . && |
81 | rm -f .gitattributes && | |
f217f0e8 EB |
82 | git reset --hard a && |
83 | git merge b && | |
18acb30e | 84 | test_cmp expected file |
f217f0e8 EB |
85 | ' |
86 | ||
18acb30e JN |
87 | test_expect_success 'Merge addition of text=auto' ' |
88 | cat <<-\EOF >expected && | |
89 | first line | |
90 | same line | |
91 | EOF | |
92 | ||
5f4e02e5 BL |
93 | if test_have_prereq NATIVE_CRLF; then |
94 | append_cr <expected >expected.temp && | |
95 | mv expected.temp expected | |
96 | fi && | |
beeeb454 | 97 | git config merge.renormalize true && |
18acb30e JN |
98 | git rm -fr . && |
99 | rm -f .gitattributes && | |
f217f0e8 EB |
100 | git reset --hard b && |
101 | git merge a && | |
18acb30e | 102 | test_cmp expected file |
f217f0e8 EB |
103 | ' |
104 | ||
beeeb454 | 105 | test_expect_success 'Detect CRLF/LF conflict after setting text=auto' ' |
5f4e02e5 BL |
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 | |
111 | else | |
112 | echo first line >>expected && | |
113 | echo same line >>expected && | |
114 | echo ======= >>expected | |
115 | fi && | |
116 | echo first line | append_cr >>expected && | |
117 | echo same line | append_cr >>expected && | |
118 | echo ">>>>>>>" >>expected && | |
beeeb454 JN |
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 | |
125 | ' | |
126 | ||
127 | test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' ' | |
5f4e02e5 BL |
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 | |
135 | else | |
136 | echo ======= >>expected && | |
137 | echo first line >>expected && | |
138 | echo same line >>expected | |
139 | fi && | |
140 | echo ">>>>>>>" >>expected && | |
beeeb454 JN |
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 | |
147 | ' | |
148 | ||
d347cee4 JN |
149 | test_expect_failure 'checkout -m after setting text=auto' ' |
150 | cat <<-\EOF >expected && | |
151 | first line | |
152 | same line | |
153 | EOF | |
154 | ||
beeeb454 | 155 | git config merge.renormalize true && |
d347cee4 JN |
156 | git rm -fr . && |
157 | rm -f .gitattributes && | |
158 | git reset --hard initial && | |
159 | git checkout a -- . && | |
160 | git checkout -m b && | |
161 | test_cmp expected file | |
162 | ' | |
163 | ||
164 | test_expect_failure 'checkout -m addition of text=auto' ' | |
165 | cat <<-\EOF >expected && | |
166 | first line | |
167 | same line | |
168 | EOF | |
169 | ||
beeeb454 | 170 | git config merge.renormalize true && |
d347cee4 JN |
171 | git rm -fr . && |
172 | rm -f .gitattributes file && | |
173 | git reset --hard initial && | |
174 | git checkout b -- . && | |
175 | git checkout -m a && | |
176 | test_cmp expected file | |
177 | ' | |
178 | ||
179 | test_expect_failure 'cherry-pick patch from after text=auto was added' ' | |
180 | append_cr <<-\EOF >expected && | |
181 | first line | |
182 | same line | |
183 | EOF | |
184 | ||
beeeb454 | 185 | git config merge.renormalize true && |
d347cee4 JN |
186 | git rm -fr . && |
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 | |
191 | ' | |
192 | ||
331a1838 | 193 | test_expect_success 'Test delete/normalize conflict' ' |
18acb30e JN |
194 | git checkout -f side && |
195 | git rm -fr . && | |
196 | rm -f .gitattributes && | |
f217f0e8 EB |
197 | git reset --hard initial && |
198 | git rm file && | |
199 | git commit -m "remove file" && | |
200 | git checkout master && | |
201 | git reset --hard a^ && | |
202 | git merge side | |
203 | ' | |
204 | ||
205 | test_done |