t6200: avoid path mangling issue on Windows
[git/mingw.git] / t / t6200-fmt-merge-msg.sh
blobff82640aeeda3bfd0a26369427e68119b4cbf9fd
1 #!/bin/sh
3 # Copyright (c) 2006, Junio C Hamano
6 test_description='fmt-merge-msg test'
8 . ./test-lib.sh
10 test_expect_success setup '
11 echo one >one &&
12 git add one &&
13 test_tick &&
14 git commit -m "Initial" &&
16 git clone . remote &&
18 echo uno >one &&
19 echo dos >two &&
20 git add two &&
21 test_tick &&
22 git commit -a -m "Second" &&
24 git checkout -b left &&
26 echo "c1" >one &&
27 test_tick &&
28 git commit -a -m "Common #1" &&
30 echo "c2" >one &&
31 test_tick &&
32 git commit -a -m "Common #2" &&
34 git branch right &&
36 echo "l3" >two &&
37 test_tick &&
38 GIT_COMMITTER_NAME="Another Committer" \
39 GIT_AUTHOR_NAME="Another Author" git commit -a -m "Left #3" &&
41 echo "l4" >two &&
42 test_tick &&
43 GIT_COMMITTER_NAME="Another Committer" \
44 GIT_AUTHOR_NAME="Another Author" git commit -a -m "Left #4" &&
46 echo "l5" >two &&
47 test_tick &&
48 GIT_COMMITTER_NAME="Another Committer" \
49 GIT_AUTHOR_NAME="Another Author" git commit -a -m "Left #5" &&
50 git tag tag-l5 &&
52 git checkout right &&
54 echo "r3" >three &&
55 git add three &&
56 test_tick &&
57 git commit -a -m "Right #3" &&
58 git tag tag-r3 &&
60 echo "r4" >three &&
61 test_tick &&
62 git commit -a -m "Right #4" &&
64 echo "r5" >three &&
65 test_tick &&
66 git commit -a -m "Right #5" &&
68 git checkout -b long &&
69 i=0 &&
70 while test $i -lt 30
72 test_commit $i one &&
73 i=$(($i+1))
74 done &&
76 git show-branch &&
78 apos="'\''"
81 test_expect_success 'message for merging local branch' '
82 echo "Merge branch ${apos}left${apos}" >expected &&
84 git checkout master &&
85 git fetch . left &&
87 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
88 test_cmp expected actual
91 test_expect_success 'message for merging external branch' '
92 echo "Merge branch ${apos}left${apos} of $(pwd)" >expected &&
94 git checkout master &&
95 git fetch "$(pwd)" left &&
97 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
98 test_cmp expected actual
101 test_expect_success '[merge] summary/log configuration' '
102 cat >expected <<-EOF &&
103 Merge branch ${apos}left${apos}
105 # By Another Author (3) and A U Thor (2)
106 # Via Another Committer
107 * left:
108 Left #5
109 Left #4
110 Left #3
111 Common #2
112 Common #1
115 git config merge.log true &&
116 test_might_fail git config --unset-all merge.summary &&
118 git checkout master &&
119 test_tick &&
120 git fetch . left &&
122 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
124 test_might_fail git config --unset-all merge.log &&
125 git config merge.summary true &&
127 git checkout master &&
128 test_tick &&
129 git fetch . left &&
131 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
133 test_cmp expected actual1 &&
134 test_cmp expected actual2
137 test_expect_success 'setup: clear [merge] configuration' '
138 test_might_fail git config --unset-all merge.log &&
139 test_might_fail git config --unset-all merge.summary
142 test_expect_success 'setup FETCH_HEAD' '
143 git checkout master &&
144 test_tick &&
145 git fetch . left
148 test_expect_success 'merge.log=3 limits shortlog length' '
149 cat >expected <<-EOF &&
150 Merge branch ${apos}left${apos}
152 # By Another Author (3) and A U Thor (2)
153 # Via Another Committer
154 * left: (5 commits)
155 Left #5
156 Left #4
157 Left #3
161 git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >actual &&
162 test_cmp expected actual
165 test_expect_success 'merge.log=5 shows all 5 commits' '
166 cat >expected <<-EOF &&
167 Merge branch ${apos}left${apos}
169 # By Another Author (3) and A U Thor (2)
170 # Via Another Committer
171 * left:
172 Left #5
173 Left #4
174 Left #3
175 Common #2
176 Common #1
179 git -c merge.log=5 fmt-merge-msg <.git/FETCH_HEAD >actual &&
180 test_cmp expected actual
183 test_expect_success '--log=5 with custom comment character' '
184 cat >expected <<-EOF &&
185 Merge branch ${apos}left${apos}
187 x By Another Author (3) and A U Thor (2)
188 x Via Another Committer
189 * left:
190 Left #5
191 Left #4
192 Left #3
193 Common #2
194 Common #1
197 git -c core.commentchar="x" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
198 test_cmp expected actual
201 test_expect_success 'merge.log=0 disables shortlog' '
202 echo "Merge branch ${apos}left${apos}" >expected
203 git -c merge.log=0 fmt-merge-msg <.git/FETCH_HEAD >actual &&
204 test_cmp expected actual
207 test_expect_success '--log=3 limits shortlog length' '
208 cat >expected <<-EOF &&
209 Merge branch ${apos}left${apos}
211 # By Another Author (3) and A U Thor (2)
212 # Via Another Committer
213 * left: (5 commits)
214 Left #5
215 Left #4
216 Left #3
220 git fmt-merge-msg --log=3 <.git/FETCH_HEAD >actual &&
221 test_cmp expected actual
224 test_expect_success '--log=5 shows all 5 commits' '
225 cat >expected <<-EOF &&
226 Merge branch ${apos}left${apos}
228 # By Another Author (3) and A U Thor (2)
229 # Via Another Committer
230 * left:
231 Left #5
232 Left #4
233 Left #3
234 Common #2
235 Common #1
238 git fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
239 test_cmp expected actual
242 test_expect_success '--no-log disables shortlog' '
243 echo "Merge branch ${apos}left${apos}" >expected &&
244 git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual &&
245 test_cmp expected actual
248 test_expect_success '--log=0 disables shortlog' '
249 echo "Merge branch ${apos}left${apos}" >expected &&
250 git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual &&
251 test_cmp expected actual
254 test_expect_success 'fmt-merge-msg -m' '
255 echo "Sync with left" >expected &&
256 cat >expected.log <<-EOF &&
257 Sync with left
259 # By Another Author (3) and A U Thor (2)
260 # Via Another Committer
261 * ${apos}left${apos} of $(pwd):
262 Left #5
263 Left #4
264 Left #3
265 Common #2
266 Common #1
269 test_might_fail git config --unset merge.log &&
270 test_might_fail git config --unset merge.summary &&
271 git checkout master &&
272 git fetch "$(pwd)" left &&
273 git fmt-merge-msg -m "Sync with left" <.git/FETCH_HEAD >actual &&
274 git fmt-merge-msg --log -m "Sync with left" \
275 <.git/FETCH_HEAD >actual.log &&
276 git config merge.log true &&
277 git fmt-merge-msg -m "Sync with left" \
278 <.git/FETCH_HEAD >actual.log-config &&
279 git fmt-merge-msg --no-log -m "Sync with left" \
280 <.git/FETCH_HEAD >actual.nolog &&
282 test_cmp expected actual &&
283 test_cmp expected.log actual.log &&
284 test_cmp expected.log actual.log-config &&
285 test_cmp expected actual.nolog
288 test_expect_success 'setup: expected shortlog for two branches' '
289 cat >expected <<-EOF
290 Merge branches ${apos}left${apos} and ${apos}right${apos}
292 # By Another Author (3) and A U Thor (2)
293 # Via Another Committer
294 * left:
295 Left #5
296 Left #4
297 Left #3
298 Common #2
299 Common #1
301 * right:
302 Right #5
303 Right #4
304 Right #3
305 Common #2
306 Common #1
310 test_expect_success 'shortlog for two branches' '
311 git config merge.log true &&
312 test_might_fail git config --unset-all merge.summary &&
313 git checkout master &&
314 test_tick &&
315 git fetch . left right &&
316 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
318 test_might_fail git config --unset-all merge.log &&
319 git config merge.summary true &&
320 git checkout master &&
321 test_tick &&
322 git fetch . left right &&
323 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
325 git config merge.log yes &&
326 test_might_fail git config --unset-all merge.summary &&
327 git checkout master &&
328 test_tick &&
329 git fetch . left right &&
330 git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
332 test_might_fail git config --unset-all merge.log &&
333 git config merge.summary yes &&
334 git checkout master &&
335 test_tick &&
336 git fetch . left right &&
337 git fmt-merge-msg <.git/FETCH_HEAD >actual4 &&
339 test_cmp expected actual1 &&
340 test_cmp expected actual2 &&
341 test_cmp expected actual3 &&
342 test_cmp expected actual4
345 test_expect_success 'merge-msg -F' '
346 test_might_fail git config --unset-all merge.log &&
347 git config merge.summary yes &&
348 git checkout master &&
349 test_tick &&
350 git fetch . left right &&
351 git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
352 test_cmp expected actual
355 test_expect_success 'merge-msg -F in subdirectory' '
356 test_might_fail git config --unset-all merge.log &&
357 git config merge.summary yes &&
358 git checkout master &&
359 test_tick &&
360 git fetch . left right &&
361 mkdir sub &&
362 cp .git/FETCH_HEAD sub/FETCH_HEAD &&
364 cd sub &&
365 git fmt-merge-msg -F FETCH_HEAD >../actual
366 ) &&
367 test_cmp expected actual
370 test_expect_success 'merge-msg with nothing to merge' '
371 test_might_fail git config --unset-all merge.log &&
372 git config merge.summary yes &&
374 >empty &&
377 cd remote &&
378 git checkout -b unrelated &&
379 test_tick &&
380 git fetch origin &&
381 git fmt-merge-msg <.git/FETCH_HEAD >../actual
382 ) &&
384 test_cmp empty actual
387 test_expect_success 'merge-msg tag' '
388 cat >expected <<-EOF &&
389 Merge tag ${apos}tag-r3${apos}
391 * tag ${apos}tag-r3${apos}:
392 Right #3
393 Common #2
394 Common #1
397 test_might_fail git config --unset-all merge.log &&
398 git config merge.summary yes &&
400 git checkout master &&
401 test_tick &&
402 git fetch . tag tag-r3 &&
404 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
405 test_cmp expected actual
408 test_expect_success 'merge-msg two tags' '
409 cat >expected <<-EOF &&
410 Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos}
412 * tag ${apos}tag-r3${apos}:
413 Right #3
414 Common #2
415 Common #1
417 # By Another Author (3) and A U Thor (2)
418 # Via Another Committer
419 * tag ${apos}tag-l5${apos}:
420 Left #5
421 Left #4
422 Left #3
423 Common #2
424 Common #1
427 test_might_fail git config --unset-all merge.log &&
428 git config merge.summary yes &&
430 git checkout master &&
431 test_tick &&
432 git fetch . tag tag-r3 tag tag-l5 &&
434 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
435 test_cmp expected actual
438 test_expect_success 'merge-msg tag and branch' '
439 cat >expected <<-EOF &&
440 Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos}
442 * tag ${apos}tag-r3${apos}:
443 Right #3
444 Common #2
445 Common #1
447 # By Another Author (3) and A U Thor (2)
448 # Via Another Committer
449 * left:
450 Left #5
451 Left #4
452 Left #3
453 Common #2
454 Common #1
457 test_might_fail git config --unset-all merge.log &&
458 git config merge.summary yes &&
460 git checkout master &&
461 test_tick &&
462 git fetch . tag tag-r3 left &&
464 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
465 test_cmp expected actual
468 test_expect_success 'merge-msg lots of commits' '
470 cat <<-EOF &&
471 Merge branch ${apos}long${apos}
473 * long: (35 commits)
476 i=29 &&
477 while test $i -gt 9
479 echo " $i" &&
480 i=$(($i-1))
481 done &&
482 echo " ..."
483 } >expected &&
485 git checkout master &&
486 test_tick &&
487 git fetch . long &&
489 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
490 test_cmp expected actual
493 test_done