config.c: trivial fix for compile-time warning
[git/dscho.git] / t / t6200-fmt-merge-msg.sh
blobb90015df1c85b4acc3f53f1312b6aaa63d44cc7c
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 'merge.log=0 disables shortlog' '
184 echo "Merge branch ${apos}left${apos}" >expected
185 git -c merge.log=0 fmt-merge-msg <.git/FETCH_HEAD >actual &&
186 test_cmp expected actual
189 test_expect_success '--log=3 limits shortlog length' '
190 cat >expected <<-EOF &&
191 Merge branch ${apos}left${apos}
193 By Another Author (3) and A U Thor (2)
194 via Another Committer
195 * left: (5 commits)
196 Left #5
197 Left #4
198 Left #3
202 git fmt-merge-msg --log=3 <.git/FETCH_HEAD >actual &&
203 test_cmp expected actual
206 test_expect_success '--log=5 shows all 5 commits' '
207 cat >expected <<-EOF &&
208 Merge branch ${apos}left${apos}
210 By Another Author (3) and A U Thor (2)
211 via Another Committer
212 * left:
213 Left #5
214 Left #4
215 Left #3
216 Common #2
217 Common #1
220 git fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
221 test_cmp expected actual
224 test_expect_success '--no-log disables shortlog' '
225 echo "Merge branch ${apos}left${apos}" >expected &&
226 git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual &&
227 test_cmp expected actual
230 test_expect_success '--log=0 disables shortlog' '
231 echo "Merge branch ${apos}left${apos}" >expected &&
232 git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual &&
233 test_cmp expected actual
236 test_expect_success 'fmt-merge-msg -m' '
237 echo "Sync with left" >expected &&
238 cat >expected.log <<-EOF &&
239 Sync with left
241 By Another Author (3) and A U Thor (2)
242 via Another Committer
243 * ${apos}left${apos} of $(pwd):
244 Left #5
245 Left #4
246 Left #3
247 Common #2
248 Common #1
251 test_might_fail git config --unset merge.log &&
252 test_might_fail git config --unset merge.summary &&
253 git checkout master &&
254 git fetch "$(pwd)" left &&
255 git fmt-merge-msg -m "Sync with left" <.git/FETCH_HEAD >actual &&
256 git fmt-merge-msg --log -m "Sync with left" \
257 <.git/FETCH_HEAD >actual.log &&
258 git config merge.log true &&
259 git fmt-merge-msg -m "Sync with left" \
260 <.git/FETCH_HEAD >actual.log-config &&
261 git fmt-merge-msg --no-log -m "Sync with left" \
262 <.git/FETCH_HEAD >actual.nolog &&
264 test_cmp expected actual &&
265 test_cmp expected.log actual.log &&
266 test_cmp expected.log actual.log-config &&
267 test_cmp expected actual.nolog
270 test_expect_success 'setup: expected shortlog for two branches' '
271 cat >expected <<-EOF
272 Merge branches ${apos}left${apos} and ${apos}right${apos}
274 By Another Author (3) and A U Thor (2)
275 via Another Committer
276 * left:
277 Left #5
278 Left #4
279 Left #3
280 Common #2
281 Common #1
283 By A U Thor
284 * right:
285 Right #5
286 Right #4
287 Right #3
288 Common #2
289 Common #1
293 test_expect_success 'shortlog for two branches' '
294 git config merge.log true &&
295 test_might_fail git config --unset-all merge.summary &&
296 git checkout master &&
297 test_tick &&
298 git fetch . left right &&
299 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
301 test_might_fail git config --unset-all merge.log &&
302 git config merge.summary true &&
303 git checkout master &&
304 test_tick &&
305 git fetch . left right &&
306 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
308 git config merge.log yes &&
309 test_might_fail git config --unset-all merge.summary &&
310 git checkout master &&
311 test_tick &&
312 git fetch . left right &&
313 git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
315 test_might_fail git config --unset-all merge.log &&
316 git config merge.summary yes &&
317 git checkout master &&
318 test_tick &&
319 git fetch . left right &&
320 git fmt-merge-msg <.git/FETCH_HEAD >actual4 &&
322 test_cmp expected actual1 &&
323 test_cmp expected actual2 &&
324 test_cmp expected actual3 &&
325 test_cmp expected actual4
328 test_expect_success 'merge-msg -F' '
329 test_might_fail git config --unset-all merge.log &&
330 git config merge.summary yes &&
331 git checkout master &&
332 test_tick &&
333 git fetch . left right &&
334 git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
335 test_cmp expected actual
338 test_expect_success 'merge-msg -F in subdirectory' '
339 test_might_fail git config --unset-all merge.log &&
340 git config merge.summary yes &&
341 git checkout master &&
342 test_tick &&
343 git fetch . left right &&
344 mkdir sub &&
345 cp .git/FETCH_HEAD sub/FETCH_HEAD &&
347 cd sub &&
348 git fmt-merge-msg -F FETCH_HEAD >../actual
349 ) &&
350 test_cmp expected actual
353 test_expect_success 'merge-msg with nothing to merge' '
354 test_might_fail git config --unset-all merge.log &&
355 git config merge.summary yes &&
357 >empty &&
360 cd remote &&
361 git checkout -b unrelated &&
362 test_tick &&
363 git fetch origin &&
364 git fmt-merge-msg <.git/FETCH_HEAD >../actual
365 ) &&
367 test_cmp empty actual
370 test_expect_success 'merge-msg tag' '
371 cat >expected <<-EOF &&
372 Merge tag ${apos}tag-r3${apos}
374 By A U Thor
375 * tag ${apos}tag-r3${apos}:
376 Right #3
377 Common #2
378 Common #1
381 test_might_fail git config --unset-all merge.log &&
382 git config merge.summary yes &&
384 git checkout master &&
385 test_tick &&
386 git fetch . tag tag-r3 &&
388 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
389 test_cmp expected actual
392 test_expect_success 'merge-msg two tags' '
393 cat >expected <<-EOF &&
394 Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos}
396 By A U Thor
397 * tag ${apos}tag-r3${apos}:
398 Right #3
399 Common #2
400 Common #1
402 By Another Author (3) and A U Thor (2)
403 via Another Committer
404 * tag ${apos}tag-l5${apos}:
405 Left #5
406 Left #4
407 Left #3
408 Common #2
409 Common #1
412 test_might_fail git config --unset-all merge.log &&
413 git config merge.summary yes &&
415 git checkout master &&
416 test_tick &&
417 git fetch . tag tag-r3 tag tag-l5 &&
419 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
420 test_cmp expected actual
423 test_expect_success 'merge-msg tag and branch' '
424 cat >expected <<-EOF &&
425 Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos}
427 By A U Thor
428 * tag ${apos}tag-r3${apos}:
429 Right #3
430 Common #2
431 Common #1
433 By Another Author (3) and A U Thor (2)
434 via Another Committer
435 * left:
436 Left #5
437 Left #4
438 Left #3
439 Common #2
440 Common #1
443 test_might_fail git config --unset-all merge.log &&
444 git config merge.summary yes &&
446 git checkout master &&
447 test_tick &&
448 git fetch . tag tag-r3 left &&
450 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
451 test_cmp expected actual
454 test_expect_success 'merge-msg lots of commits' '
456 cat <<-EOF &&
457 Merge branch ${apos}long${apos}
459 By A U Thor
460 * long: (35 commits)
463 i=29 &&
464 while test $i -gt 9
466 echo " $i" &&
467 i=$(($i-1))
468 done &&
469 echo " ..."
470 } >expected &&
472 git checkout master &&
473 test_tick &&
474 git fetch . long &&
476 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
477 test_cmp expected actual
480 test_done