]>
Commit | Line | Data |
---|---|---|
30a95f30 JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006, Junio C Hamano | |
4 | # | |
5 | ||
6 | test_description='fmt-merge-msg test' | |
7 | ||
8 | . ./test-lib.sh | |
9 | ||
30a95f30 JH |
10 | test_expect_success setup ' |
11 | echo one >one && | |
12 | git add one && | |
6183a6ad | 13 | test_tick && |
30a95f30 JH |
14 | git commit -m "Initial" && |
15 | ||
419fe5bc SB |
16 | git clone . remote && |
17 | ||
30a95f30 JH |
18 | echo uno >one && |
19 | echo dos >two && | |
20 | git add two && | |
6183a6ad | 21 | test_tick && |
30a95f30 JH |
22 | git commit -a -m "Second" && |
23 | ||
24 | git checkout -b left && | |
25 | ||
6183a6ad SB |
26 | echo "c1" >one && |
27 | test_tick && | |
30a95f30 JH |
28 | git commit -a -m "Common #1" && |
29 | ||
6183a6ad SB |
30 | echo "c2" >one && |
31 | test_tick && | |
30a95f30 JH |
32 | git commit -a -m "Common #2" && |
33 | ||
34 | git branch right && | |
35 | ||
6183a6ad SB |
36 | echo "l3" >two && |
37 | test_tick && | |
30a95f30 JH |
38 | git commit -a -m "Left #3" && |
39 | ||
6183a6ad SB |
40 | echo "l4" >two && |
41 | test_tick && | |
30a95f30 JH |
42 | git commit -a -m "Left #4" && |
43 | ||
6183a6ad SB |
44 | echo "l5" >two && |
45 | test_tick && | |
30a95f30 | 46 | git commit -a -m "Left #5" && |
6183a6ad | 47 | git tag tag-l5 && |
30a95f30 JH |
48 | |
49 | git checkout right && | |
50 | ||
6183a6ad | 51 | echo "r3" >three && |
30a95f30 | 52 | git add three && |
6183a6ad | 53 | test_tick && |
30a95f30 | 54 | git commit -a -m "Right #3" && |
6183a6ad | 55 | git tag tag-r3 && |
30a95f30 | 56 | |
6183a6ad SB |
57 | echo "r4" >three && |
58 | test_tick && | |
30a95f30 JH |
59 | git commit -a -m "Right #4" && |
60 | ||
6183a6ad SB |
61 | echo "r5" >three && |
62 | test_tick && | |
30a95f30 JH |
63 | git commit -a -m "Right #5" && |
64 | ||
6d6f6e68 SB |
65 | git checkout -b long && |
66 | i=0 && | |
67 | while test $i -lt 30 | |
68 | do | |
69 | test_commit $i one && | |
70 | i=$(($i+1)) | |
71 | done && | |
72 | ||
d834c96a | 73 | git show-branch && |
30a95f30 | 74 | |
d834c96a JN |
75 | apos="'\''" |
76 | ' | |
30a95f30 | 77 | |
d834c96a JN |
78 | test_expect_success 'message for merging local branch' ' |
79 | echo "Merge branch ${apos}left${apos}" >expected && | |
30a95f30 JH |
80 | |
81 | git checkout master && | |
82 | git fetch . left && | |
83 | ||
84 | git fmt-merge-msg <.git/FETCH_HEAD >actual && | |
3af82863 | 85 | test_cmp expected actual |
30a95f30 JH |
86 | ' |
87 | ||
d834c96a JN |
88 | test_expect_success 'message for merging external branch' ' |
89 | echo "Merge branch ${apos}left${apos} of $(pwd)" >expected && | |
30a95f30 JH |
90 | |
91 | git checkout master && | |
4114156a | 92 | git fetch "$(pwd)" left && |
30a95f30 JH |
93 | |
94 | git fmt-merge-msg <.git/FETCH_HEAD >actual && | |
3af82863 | 95 | test_cmp expected actual |
30a95f30 JH |
96 | ' |
97 | ||
d834c96a JN |
98 | test_expect_success '[merge] summary/log configuration' ' |
99 | cat >expected <<-EOF && | |
100 | Merge branch ${apos}left${apos} | |
30a95f30 | 101 | |
d834c96a JN |
102 | * left: |
103 | Left #5 | |
104 | Left #4 | |
105 | Left #3 | |
106 | Common #2 | |
107 | Common #1 | |
108 | EOF | |
30a95f30 | 109 | |
6cd9cfef | 110 | git config merge.log true && |
d834c96a | 111 | test_might_fail git config --unset-all merge.summary && |
6cd9cfef SG |
112 | |
113 | git checkout master && | |
6183a6ad | 114 | test_tick && |
6cd9cfef SG |
115 | git fetch . left && |
116 | ||
d834c96a | 117 | git fmt-merge-msg <.git/FETCH_HEAD >actual1 && |
6cd9cfef | 118 | |
d834c96a | 119 | test_might_fail git config --unset-all merge.log && |
e0d10e1c | 120 | git config merge.summary true && |
30a95f30 JH |
121 | |
122 | git checkout master && | |
6183a6ad | 123 | test_tick && |
30a95f30 JH |
124 | git fetch . left && |
125 | ||
d834c96a | 126 | git fmt-merge-msg <.git/FETCH_HEAD >actual2 && |
30a95f30 | 127 | |
d834c96a JN |
128 | test_cmp expected actual1 && |
129 | test_cmp expected actual2 | |
130 | ' | |
30a95f30 | 131 | |
b928cbf1 RR |
132 | test_expect_success 'setup: clear [merge] configuration' ' |
133 | test_might_fail git config --unset-all merge.log && | |
134 | test_might_fail git config --unset-all merge.summary | |
135 | ' | |
136 | ||
137 | test_expect_success 'setup FETCH_HEAD' ' | |
138 | git checkout master && | |
139 | test_tick && | |
140 | git fetch . left | |
141 | ' | |
142 | ||
143 | test_expect_success 'merge.log=3 limits shortlog length' ' | |
144 | cat >expected <<-EOF && | |
145 | Merge branch ${apos}left${apos} | |
146 | ||
147 | * left: (5 commits) | |
148 | Left #5 | |
149 | Left #4 | |
150 | Left #3 | |
151 | ... | |
152 | EOF | |
153 | ||
154 | git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >actual && | |
155 | test_cmp expected actual | |
156 | ' | |
157 | ||
158 | test_expect_success 'merge.log=5 shows all 5 commits' ' | |
159 | cat >expected <<-EOF && | |
160 | Merge branch ${apos}left${apos} | |
161 | ||
162 | * left: | |
163 | Left #5 | |
164 | Left #4 | |
165 | Left #3 | |
166 | Common #2 | |
167 | Common #1 | |
168 | EOF | |
169 | ||
170 | git -c merge.log=5 fmt-merge-msg <.git/FETCH_HEAD >actual && | |
171 | test_cmp expected actual | |
172 | ' | |
173 | ||
174 | test_expect_success 'merge.log=0 disables shortlog' ' | |
175 | echo "Merge branch ${apos}left${apos}" >expected | |
176 | git -c merge.log=0 fmt-merge-msg <.git/FETCH_HEAD >actual && | |
177 | test_cmp expected actual | |
178 | ' | |
179 | ||
bd2549ca RR |
180 | test_expect_success '--log=3 limits shortlog length' ' |
181 | cat >expected <<-EOF && | |
182 | Merge branch ${apos}left${apos} | |
183 | ||
184 | * left: (5 commits) | |
185 | Left #5 | |
186 | Left #4 | |
187 | Left #3 | |
188 | ... | |
189 | EOF | |
190 | ||
191 | git fmt-merge-msg --log=3 <.git/FETCH_HEAD >actual && | |
192 | test_cmp expected actual | |
193 | ' | |
194 | ||
195 | test_expect_success '--log=5 shows all 5 commits' ' | |
196 | cat >expected <<-EOF && | |
197 | Merge branch ${apos}left${apos} | |
198 | ||
199 | * left: | |
200 | Left #5 | |
201 | Left #4 | |
202 | Left #3 | |
203 | Common #2 | |
204 | Common #1 | |
205 | EOF | |
206 | ||
207 | git fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual && | |
208 | test_cmp expected actual | |
209 | ' | |
210 | ||
211 | test_expect_success '--no-log disables shortlog' ' | |
212 | echo "Merge branch ${apos}left${apos}" >expected && | |
213 | git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual && | |
214 | test_cmp expected actual | |
215 | ' | |
216 | ||
217 | test_expect_success '--log=0 disables shortlog' ' | |
218 | echo "Merge branch ${apos}left${apos}" >expected && | |
219 | git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual && | |
220 | test_cmp expected actual | |
221 | ' | |
222 | ||
2102440c JN |
223 | test_expect_success 'fmt-merge-msg -m' ' |
224 | echo "Sync with left" >expected && | |
225 | cat >expected.log <<-EOF && | |
226 | Sync with left | |
227 | ||
228 | * ${apos}left${apos} of $(pwd): | |
229 | Left #5 | |
230 | Left #4 | |
231 | Left #3 | |
232 | Common #2 | |
233 | Common #1 | |
234 | EOF | |
235 | ||
236 | test_might_fail git config --unset merge.log && | |
237 | test_might_fail git config --unset merge.summary && | |
238 | git checkout master && | |
239 | git fetch "$(pwd)" left && | |
240 | git fmt-merge-msg -m "Sync with left" <.git/FETCH_HEAD >actual && | |
241 | git fmt-merge-msg --log -m "Sync with left" \ | |
242 | <.git/FETCH_HEAD >actual.log && | |
243 | git config merge.log true && | |
244 | git fmt-merge-msg -m "Sync with left" \ | |
245 | <.git/FETCH_HEAD >actual.log-config && | |
246 | git fmt-merge-msg --no-log -m "Sync with left" \ | |
247 | <.git/FETCH_HEAD >actual.nolog && | |
248 | ||
249 | test_cmp expected actual && | |
250 | test_cmp expected.log actual.log && | |
251 | test_cmp expected.log actual.log-config && | |
252 | test_cmp expected actual.nolog | |
253 | ' | |
254 | ||
d834c96a JN |
255 | test_expect_success 'setup: expected shortlog for two branches' ' |
256 | cat >expected <<-EOF | |
257 | Merge branches ${apos}left${apos} and ${apos}right${apos} | |
258 | ||
259 | * left: | |
260 | Left #5 | |
261 | Left #4 | |
262 | Left #3 | |
263 | Common #2 | |
264 | Common #1 | |
265 | ||
266 | * right: | |
267 | Right #5 | |
268 | Right #4 | |
269 | Right #3 | |
270 | Common #2 | |
271 | Common #1 | |
272 | EOF | |
273 | ' | |
6cd9cfef | 274 | |
d834c96a | 275 | test_expect_success 'shortlog for two branches' ' |
6cd9cfef | 276 | git config merge.log true && |
d834c96a | 277 | test_might_fail git config --unset-all merge.summary && |
6cd9cfef | 278 | git checkout master && |
6183a6ad | 279 | test_tick && |
6cd9cfef | 280 | git fetch . left right && |
d834c96a | 281 | git fmt-merge-msg <.git/FETCH_HEAD >actual1 && |
6cd9cfef | 282 | |
d834c96a | 283 | test_might_fail git config --unset-all merge.log && |
e0d10e1c | 284 | git config merge.summary true && |
30a95f30 | 285 | git checkout master && |
6183a6ad | 286 | test_tick && |
30a95f30 | 287 | git fetch . left right && |
d834c96a | 288 | git fmt-merge-msg <.git/FETCH_HEAD >actual2 && |
30a95f30 | 289 | |
6cd9cfef | 290 | git config merge.log yes && |
d834c96a | 291 | test_might_fail git config --unset-all merge.summary && |
6cd9cfef | 292 | git checkout master && |
6183a6ad | 293 | test_tick && |
6cd9cfef | 294 | git fetch . left right && |
d834c96a | 295 | git fmt-merge-msg <.git/FETCH_HEAD >actual3 && |
6cd9cfef | 296 | |
d834c96a | 297 | test_might_fail git config --unset-all merge.log && |
e0d10e1c | 298 | git config merge.summary yes && |
30a95f30 | 299 | git checkout master && |
6183a6ad | 300 | test_tick && |
30a95f30 | 301 | git fetch . left right && |
d834c96a | 302 | git fmt-merge-msg <.git/FETCH_HEAD >actual4 && |
30a95f30 | 303 | |
d834c96a JN |
304 | test_cmp expected actual1 && |
305 | test_cmp expected actual2 && | |
306 | test_cmp expected actual3 && | |
307 | test_cmp expected actual4 | |
30a95f30 JH |
308 | ' |
309 | ||
4c8d4c14 | 310 | test_expect_success 'merge-msg -F' ' |
d834c96a | 311 | test_might_fail git config --unset-all merge.log && |
4c8d4c14 | 312 | git config merge.summary yes && |
4c8d4c14 | 313 | git checkout master && |
6183a6ad | 314 | test_tick && |
4c8d4c14 | 315 | git fetch . left right && |
4c8d4c14 SB |
316 | git fmt-merge-msg -F .git/FETCH_HEAD >actual && |
317 | test_cmp expected actual | |
318 | ' | |
319 | ||
320 | test_expect_success 'merge-msg -F in subdirectory' ' | |
d834c96a | 321 | test_might_fail git config --unset-all merge.log && |
4c8d4c14 | 322 | git config merge.summary yes && |
4c8d4c14 | 323 | git checkout master && |
6183a6ad | 324 | test_tick && |
4c8d4c14 SB |
325 | git fetch . left right && |
326 | mkdir sub && | |
327 | cp .git/FETCH_HEAD sub/FETCH_HEAD && | |
328 | ( | |
329 | cd sub && | |
330 | git fmt-merge-msg -F FETCH_HEAD >../actual | |
331 | ) && | |
332 | test_cmp expected actual | |
333 | ' | |
334 | ||
419fe5bc | 335 | test_expect_success 'merge-msg with nothing to merge' ' |
d834c96a | 336 | test_might_fail git config --unset-all merge.log && |
419fe5bc SB |
337 | git config merge.summary yes && |
338 | ||
d834c96a JN |
339 | >empty && |
340 | ||
419fe5bc SB |
341 | ( |
342 | cd remote && | |
343 | git checkout -b unrelated && | |
6183a6ad | 344 | test_tick && |
419fe5bc SB |
345 | git fetch origin && |
346 | git fmt-merge-msg <.git/FETCH_HEAD >../actual | |
347 | ) && | |
348 | ||
d834c96a | 349 | test_cmp empty actual |
419fe5bc SB |
350 | ' |
351 | ||
6d6f6e68 | 352 | test_expect_success 'merge-msg tag' ' |
d834c96a JN |
353 | cat >expected <<-EOF && |
354 | Merge tag ${apos}tag-r3${apos} | |
355 | ||
356 | * tag ${apos}tag-r3${apos}: | |
357 | Right #3 | |
358 | Common #2 | |
359 | Common #1 | |
360 | EOF | |
6d6f6e68 | 361 | |
d834c96a | 362 | test_might_fail git config --unset-all merge.log && |
6d6f6e68 SB |
363 | git config merge.summary yes && |
364 | ||
365 | git checkout master && | |
366 | test_tick && | |
367 | git fetch . tag tag-r3 && | |
368 | ||
369 | git fmt-merge-msg <.git/FETCH_HEAD >actual && | |
370 | test_cmp expected actual | |
371 | ' | |
372 | ||
6d6f6e68 | 373 | test_expect_success 'merge-msg two tags' ' |
d834c96a JN |
374 | cat >expected <<-EOF && |
375 | Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos} | |
376 | ||
377 | * tag ${apos}tag-r3${apos}: | |
378 | Right #3 | |
379 | Common #2 | |
380 | Common #1 | |
381 | ||
382 | * tag ${apos}tag-l5${apos}: | |
383 | Left #5 | |
384 | Left #4 | |
385 | Left #3 | |
386 | Common #2 | |
387 | Common #1 | |
388 | EOF | |
389 | ||
390 | test_might_fail git config --unset-all merge.log && | |
6d6f6e68 SB |
391 | git config merge.summary yes && |
392 | ||
393 | git checkout master && | |
394 | test_tick && | |
395 | git fetch . tag tag-r3 tag tag-l5 && | |
396 | ||
397 | git fmt-merge-msg <.git/FETCH_HEAD >actual && | |
398 | test_cmp expected actual | |
399 | ' | |
400 | ||
6d6f6e68 | 401 | test_expect_success 'merge-msg tag and branch' ' |
d834c96a JN |
402 | cat >expected <<-EOF && |
403 | Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos} | |
404 | ||
405 | * tag ${apos}tag-r3${apos}: | |
406 | Right #3 | |
407 | Common #2 | |
408 | Common #1 | |
409 | ||
410 | * left: | |
411 | Left #5 | |
412 | Left #4 | |
413 | Left #3 | |
414 | Common #2 | |
415 | Common #1 | |
416 | EOF | |
417 | ||
418 | test_might_fail git config --unset-all merge.log && | |
6d6f6e68 SB |
419 | git config merge.summary yes && |
420 | ||
421 | git checkout master && | |
422 | test_tick && | |
423 | git fetch . tag tag-r3 left && | |
424 | ||
425 | git fmt-merge-msg <.git/FETCH_HEAD >actual && | |
426 | test_cmp expected actual | |
427 | ' | |
428 | ||
6d6f6e68 | 429 | test_expect_success 'merge-msg lots of commits' ' |
d834c96a JN |
430 | { |
431 | cat <<-EOF && | |
432 | Merge branch ${apos}long${apos} | |
433 | ||
434 | * long: (35 commits) | |
435 | EOF | |
436 | ||
437 | i=29 && | |
438 | while test $i -gt 9 | |
439 | do | |
440 | echo " $i" && | |
441 | i=$(($i-1)) | |
442 | done && | |
443 | echo " ..." | |
444 | } >expected && | |
6d6f6e68 SB |
445 | |
446 | git checkout master && | |
447 | test_tick && | |
448 | git fetch . long && | |
449 | ||
6d6f6e68 SB |
450 | git fmt-merge-msg <.git/FETCH_HEAD >actual && |
451 | test_cmp expected actual | |
452 | ' | |
453 | ||
30a95f30 | 454 | test_done |