]>
Commit | Line | Data |
---|---|---|
ba1f5f35 JS |
1 | #!/bin/sh |
2 | ||
3 | test_description='RCS merge replacement: merge-file' | |
4 | . ./test-lib.sh | |
5 | ||
6 | cat > orig.txt << EOF | |
7 | Dominus regit me, | |
8 | et nihil mihi deerit. | |
9 | In loco pascuae ibi me collocavit, | |
10 | super aquam refectionis educavit me; | |
11 | animam meam convertit, | |
12 | deduxit me super semitas jusitiae, | |
13 | propter nomen suum. | |
14 | EOF | |
15 | ||
16 | cat > new1.txt << EOF | |
17 | Dominus regit me, | |
18 | et nihil mihi deerit. | |
19 | In loco pascuae ibi me collocavit, | |
20 | super aquam refectionis educavit me; | |
21 | animam meam convertit, | |
22 | deduxit me super semitas jusitiae, | |
23 | propter nomen suum. | |
24 | Nam et si ambulavero in medio umbrae mortis, | |
25 | non timebo mala, quoniam tu mecum es: | |
26 | virga tua et baculus tuus ipsa me consolata sunt. | |
27 | EOF | |
28 | ||
29 | cat > new2.txt << EOF | |
30 | Dominus regit me, et nihil mihi deerit. | |
31 | In loco pascuae ibi me collocavit, | |
32 | super aquam refectionis educavit me; | |
33 | animam meam convertit, | |
34 | deduxit me super semitas jusitiae, | |
35 | propter nomen suum. | |
36 | EOF | |
37 | ||
38 | cat > new3.txt << EOF | |
39 | DOMINUS regit me, | |
40 | et nihil mihi deerit. | |
41 | In loco pascuae ibi me collocavit, | |
42 | super aquam refectionis educavit me; | |
43 | animam meam convertit, | |
44 | deduxit me super semitas jusitiae, | |
45 | propter nomen suum. | |
46 | EOF | |
47 | ||
48 | cat > new4.txt << EOF | |
49 | Dominus regit me, et nihil mihi deerit. | |
50 | In loco pascuae ibi me collocavit, | |
51 | super aquam refectionis educavit me; | |
52 | animam meam convertit, | |
53 | deduxit me super semitas jusitiae, | |
54 | EOF | |
2aad957a | 55 | printf "propter nomen suum." >> new4.txt |
ba1f5f35 | 56 | |
5719db91 | 57 | test_expect_success 'merge with no changes' ' |
1cd12926 CB |
58 | cp orig.txt test.txt && |
59 | git merge-file test.txt orig.txt orig.txt && | |
60 | test_cmp test.txt orig.txt | |
61 | ' | |
62 | ||
ba1f5f35 JS |
63 | cp new1.txt test.txt |
64 | test_expect_success "merge without conflict" \ | |
5be60078 | 65 | "git merge-file test.txt orig.txt new2.txt" |
ba1f5f35 | 66 | |
3fdcdbdf JS |
67 | cp new1.txt test.txt |
68 | test_expect_success "merge without conflict (--quiet)" \ | |
69 | "git merge-file --quiet test.txt orig.txt new2.txt" | |
70 | ||
ba1f5f35 JS |
71 | cp new1.txt test2.txt |
72 | test_expect_success "merge without conflict (missing LF at EOF)" \ | |
5be60078 | 73 | "git merge-file test2.txt orig.txt new2.txt" |
ba1f5f35 JS |
74 | |
75 | test_expect_success "merge result added missing LF" \ | |
3af82863 | 76 | "test_cmp test.txt test2.txt" |
ba1f5f35 JS |
77 | |
78 | cp test.txt backup.txt | |
41ac414e | 79 | test_expect_success "merge with conflicts" \ |
d492b31c | 80 | "test_must_fail git merge-file test.txt orig.txt new3.txt" |
ba1f5f35 JS |
81 | |
82 | cat > expect.txt << EOF | |
83 | <<<<<<< test.txt | |
84 | Dominus regit me, et nihil mihi deerit. | |
85 | ======= | |
86 | DOMINUS regit me, | |
87 | et nihil mihi deerit. | |
88 | >>>>>>> new3.txt | |
89 | In loco pascuae ibi me collocavit, | |
90 | super aquam refectionis educavit me; | |
91 | animam meam convertit, | |
92 | deduxit me super semitas jusitiae, | |
93 | propter nomen suum. | |
94 | Nam et si ambulavero in medio umbrae mortis, | |
95 | non timebo mala, quoniam tu mecum es: | |
96 | virga tua et baculus tuus ipsa me consolata sunt. | |
97 | EOF | |
98 | ||
3af82863 | 99 | test_expect_success "expected conflict markers" "test_cmp test.txt expect.txt" |
ba1f5f35 JS |
100 | |
101 | cp backup.txt test.txt | |
41ac414e | 102 | test_expect_success "merge with conflicts, using -L" \ |
d492b31c | 103 | "test_must_fail git merge-file -L 1 -L 2 test.txt orig.txt new3.txt" |
ba1f5f35 JS |
104 | |
105 | cat > expect.txt << EOF | |
106 | <<<<<<< 1 | |
107 | Dominus regit me, et nihil mihi deerit. | |
108 | ======= | |
109 | DOMINUS regit me, | |
110 | et nihil mihi deerit. | |
111 | >>>>>>> new3.txt | |
112 | In loco pascuae ibi me collocavit, | |
113 | super aquam refectionis educavit me; | |
114 | animam meam convertit, | |
115 | deduxit me super semitas jusitiae, | |
116 | propter nomen suum. | |
117 | Nam et si ambulavero in medio umbrae mortis, | |
118 | non timebo mala, quoniam tu mecum es: | |
119 | virga tua et baculus tuus ipsa me consolata sunt. | |
120 | EOF | |
121 | ||
122 | test_expect_success "expected conflict markers, with -L" \ | |
3af82863 | 123 | "test_cmp test.txt expect.txt" |
ba1f5f35 | 124 | |
5d6b151f | 125 | sed "s/ tu / TU /" < new1.txt > new5.txt |
41ac414e | 126 | test_expect_success "conflict in removed tail" \ |
d492b31c | 127 | "test_must_fail git merge-file -p orig.txt new1.txt new5.txt > out" |
5d6b151f JS |
128 | |
129 | cat > expect << EOF | |
130 | Dominus regit me, | |
131 | et nihil mihi deerit. | |
132 | In loco pascuae ibi me collocavit, | |
133 | super aquam refectionis educavit me; | |
134 | animam meam convertit, | |
135 | deduxit me super semitas jusitiae, | |
136 | propter nomen suum. | |
137 | <<<<<<< orig.txt | |
138 | ======= | |
139 | Nam et si ambulavero in medio umbrae mortis, | |
140 | non timebo mala, quoniam TU mecum es: | |
141 | virga tua et baculus tuus ipsa me consolata sunt. | |
142 | >>>>>>> new5.txt | |
143 | EOF | |
144 | ||
3af82863 | 145 | test_expect_success "expected conflict markers" "test_cmp expect out" |
5d6b151f | 146 | |
5771907a | 147 | test_expect_success 'binary files cannot be merged' ' |
d492b31c | 148 | test_must_fail git merge-file -p \ |
bfdbee98 | 149 | orig.txt "$TEST_DIRECTORY"/test4012.png new1.txt 2> merge.err && |
5771907a JS |
150 | grep "Cannot merge binary files" merge.err |
151 | ' | |
152 | ||
9524cf29 SB |
153 | sed -e "s/deerit.\$/deerit;/" -e "s/me;\$/me./" < new5.txt > new6.txt |
154 | sed -e "s/deerit.\$/deerit,/" -e "s/me;\$/me,/" < new5.txt > new7.txt | |
f407f14d JS |
155 | |
156 | test_expect_success 'MERGE_ZEALOUS simplifies non-conflicts' ' | |
157 | ||
d492b31c | 158 | test_must_fail git merge-file -p new6.txt new5.txt new7.txt > output && |
f407f14d JS |
159 | test 1 = $(grep ======= < output | wc -l) |
160 | ||
161 | ' | |
162 | ||
10708a99 AL |
163 | sed -e 's/deerit./&%%%%/' -e "s/locavit,/locavit;/"< new6.txt | tr '%' '\012' > new8.txt |
164 | sed -e 's/deerit./&%%%%/' -e "s/locavit,/locavit --/" < new7.txt | tr '%' '\012' > new9.txt | |
ee95ec5d JS |
165 | |
166 | test_expect_success 'ZEALOUS_ALNUM' ' | |
167 | ||
d492b31c SB |
168 | test_must_fail git merge-file -p \ |
169 | new8.txt new5.txt new9.txt > merge.out && | |
ee95ec5d JS |
170 | test 1 = $(grep ======= < merge.out | wc -l) |
171 | ||
172 | ' | |
173 | ||
e0af48e4 JH |
174 | cat >expect <<\EOF |
175 | Dominus regit me, | |
176 | <<<<<<< new8.txt | |
177 | et nihil mihi deerit; | |
178 | ||
179 | ||
180 | ||
181 | ||
182 | In loco pascuae ibi me collocavit; | |
183 | super aquam refectionis educavit me. | |
184 | ||||||| | |
185 | et nihil mihi deerit. | |
186 | In loco pascuae ibi me collocavit, | |
187 | super aquam refectionis educavit me; | |
188 | ======= | |
189 | et nihil mihi deerit, | |
190 | ||
191 | ||
192 | ||
193 | ||
194 | In loco pascuae ibi me collocavit -- | |
195 | super aquam refectionis educavit me, | |
196 | >>>>>>> new9.txt | |
197 | animam meam convertit, | |
198 | deduxit me super semitas jusitiae, | |
199 | propter nomen suum. | |
200 | Nam et si ambulavero in medio umbrae mortis, | |
201 | non timebo mala, quoniam TU mecum es: | |
202 | virga tua et baculus tuus ipsa me consolata sunt. | |
203 | EOF | |
204 | ||
b5412484 | 205 | test_expect_success '"diff3 -m" style output (1)' ' |
e0af48e4 JH |
206 | test_must_fail git merge-file -p --diff3 \ |
207 | new8.txt new5.txt new9.txt >actual && | |
208 | test_cmp expect actual | |
209 | ' | |
210 | ||
b5412484 JH |
211 | test_expect_success '"diff3 -m" style output (2)' ' |
212 | git config merge.conflictstyle diff3 && | |
213 | test_must_fail git merge-file -p \ | |
214 | new8.txt new5.txt new9.txt >actual && | |
215 | test_cmp expect actual | |
216 | ' | |
217 | ||
11f3aa23 BW |
218 | cat >expect <<\EOF |
219 | Dominus regit me, | |
220 | <<<<<<<<<< new8.txt | |
221 | et nihil mihi deerit; | |
222 | ||
223 | ||
224 | ||
225 | ||
226 | In loco pascuae ibi me collocavit; | |
227 | super aquam refectionis educavit me. | |
228 | |||||||||| | |
229 | et nihil mihi deerit. | |
230 | In loco pascuae ibi me collocavit, | |
231 | super aquam refectionis educavit me; | |
232 | ========== | |
233 | et nihil mihi deerit, | |
234 | ||
235 | ||
236 | ||
237 | ||
238 | In loco pascuae ibi me collocavit -- | |
239 | super aquam refectionis educavit me, | |
240 | >>>>>>>>>> new9.txt | |
241 | animam meam convertit, | |
242 | deduxit me super semitas jusitiae, | |
243 | propter nomen suum. | |
244 | Nam et si ambulavero in medio umbrae mortis, | |
245 | non timebo mala, quoniam TU mecum es: | |
246 | virga tua et baculus tuus ipsa me consolata sunt. | |
247 | EOF | |
248 | ||
249 | test_expect_success 'marker size' ' | |
250 | test_must_fail git merge-file -p --marker-size=10 \ | |
251 | new8.txt new5.txt new9.txt >actual && | |
252 | test_cmp expect actual | |
253 | ' | |
254 | ||
ba1f5f35 | 255 | test_done |