Documentation: clarify effects of -- <path> arguments
[git/mingw/j6t.git] / t / t6200-fmt-merge-msg.sh
blob9a168069217ef8d82173e563a04eaefe58d99f2a
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 commit -a -m "Left #3" &&
40 echo "l4" >two &&
41 test_tick &&
42 git commit -a -m "Left #4" &&
44 echo "l5" >two &&
45 test_tick &&
46 git commit -a -m "Left #5" &&
47 git tag tag-l5 &&
49 git checkout right &&
51 echo "r3" >three &&
52 git add three &&
53 test_tick &&
54 git commit -a -m "Right #3" &&
55 git tag tag-r3 &&
57 echo "r4" >three &&
58 test_tick &&
59 git commit -a -m "Right #4" &&
61 echo "r5" >three &&
62 test_tick &&
63 git commit -a -m "Right #5" &&
65 git checkout -b long &&
66 i=0 &&
67 while test $i -lt 30
69 test_commit $i one &&
70 i=$(($i+1))
71 done &&
73 git show-branch &&
75 apos="'\''"
78 test_expect_success 'message for merging local branch' '
79 echo "Merge branch ${apos}left${apos}" >expected &&
81 git checkout master &&
82 git fetch . left &&
84 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
85 test_cmp expected actual
88 test_expect_success 'message for merging external branch' '
89 echo "Merge branch ${apos}left${apos} of $(pwd)" >expected &&
91 git checkout master &&
92 git fetch "$(pwd)" left &&
94 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
95 test_cmp expected actual
98 test_expect_success '[merge] summary/log configuration' '
99 cat >expected <<-EOF &&
100 Merge branch ${apos}left${apos}
102 * left:
103 Left #5
104 Left #4
105 Left #3
106 Common #2
107 Common #1
110 git config merge.log true &&
111 test_might_fail git config --unset-all merge.summary &&
113 git checkout master &&
114 test_tick &&
115 git fetch . left &&
117 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
119 test_might_fail git config --unset-all merge.log &&
120 git config merge.summary true &&
122 git checkout master &&
123 test_tick &&
124 git fetch . left &&
126 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
128 test_cmp expected actual1 &&
129 test_cmp expected actual2
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
137 test_expect_success 'setup FETCH_HEAD' '
138 git checkout master &&
139 test_tick &&
140 git fetch . left
143 test_expect_success 'merge.log=3 limits shortlog length' '
144 cat >expected <<-EOF &&
145 Merge branch ${apos}left${apos}
147 * left: (5 commits)
148 Left #5
149 Left #4
150 Left #3
154 git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >actual &&
155 test_cmp expected actual
158 test_expect_success 'merge.log=5 shows all 5 commits' '
159 cat >expected <<-EOF &&
160 Merge branch ${apos}left${apos}
162 * left:
163 Left #5
164 Left #4
165 Left #3
166 Common #2
167 Common #1
170 git -c merge.log=5 fmt-merge-msg <.git/FETCH_HEAD >actual &&
171 test_cmp expected actual
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
180 test_expect_success '--log=3 limits shortlog length' '
181 cat >expected <<-EOF &&
182 Merge branch ${apos}left${apos}
184 * left: (5 commits)
185 Left #5
186 Left #4
187 Left #3
191 git fmt-merge-msg --log=3 <.git/FETCH_HEAD >actual &&
192 test_cmp expected actual
195 test_expect_success '--log=5 shows all 5 commits' '
196 cat >expected <<-EOF &&
197 Merge branch ${apos}left${apos}
199 * left:
200 Left #5
201 Left #4
202 Left #3
203 Common #2
204 Common #1
207 git fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
208 test_cmp expected actual
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
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
223 test_expect_success 'fmt-merge-msg -m' '
224 echo "Sync with left" >expected &&
225 cat >expected.log <<-EOF &&
226 Sync with left
228 * ${apos}left${apos} of $(pwd):
229 Left #5
230 Left #4
231 Left #3
232 Common #2
233 Common #1
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 &&
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
255 test_expect_success 'setup: expected shortlog for two branches' '
256 cat >expected <<-EOF
257 Merge branches ${apos}left${apos} and ${apos}right${apos}
259 * left:
260 Left #5
261 Left #4
262 Left #3
263 Common #2
264 Common #1
266 * right:
267 Right #5
268 Right #4
269 Right #3
270 Common #2
271 Common #1
275 test_expect_success 'shortlog for two branches' '
276 git config merge.log true &&
277 test_might_fail git config --unset-all merge.summary &&
278 git checkout master &&
279 test_tick &&
280 git fetch . left right &&
281 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
283 test_might_fail git config --unset-all merge.log &&
284 git config merge.summary true &&
285 git checkout master &&
286 test_tick &&
287 git fetch . left right &&
288 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
290 git config merge.log yes &&
291 test_might_fail git config --unset-all merge.summary &&
292 git checkout master &&
293 test_tick &&
294 git fetch . left right &&
295 git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
297 test_might_fail git config --unset-all merge.log &&
298 git config merge.summary yes &&
299 git checkout master &&
300 test_tick &&
301 git fetch . left right &&
302 git fmt-merge-msg <.git/FETCH_HEAD >actual4 &&
304 test_cmp expected actual1 &&
305 test_cmp expected actual2 &&
306 test_cmp expected actual3 &&
307 test_cmp expected actual4
310 test_expect_success 'merge-msg -F' '
311 test_might_fail git config --unset-all merge.log &&
312 git config merge.summary yes &&
313 git checkout master &&
314 test_tick &&
315 git fetch . left right &&
316 git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
317 test_cmp expected actual
320 test_expect_success 'merge-msg -F in subdirectory' '
321 test_might_fail git config --unset-all merge.log &&
322 git config merge.summary yes &&
323 git checkout master &&
324 test_tick &&
325 git fetch . left right &&
326 mkdir sub &&
327 cp .git/FETCH_HEAD sub/FETCH_HEAD &&
329 cd sub &&
330 git fmt-merge-msg -F FETCH_HEAD >../actual
331 ) &&
332 test_cmp expected actual
335 test_expect_success 'merge-msg with nothing to merge' '
336 test_might_fail git config --unset-all merge.log &&
337 git config merge.summary yes &&
339 >empty &&
342 cd remote &&
343 git checkout -b unrelated &&
344 test_tick &&
345 git fetch origin &&
346 git fmt-merge-msg <.git/FETCH_HEAD >../actual
347 ) &&
349 test_cmp empty actual
352 test_expect_success 'merge-msg tag' '
353 cat >expected <<-EOF &&
354 Merge tag ${apos}tag-r3${apos}
356 * tag ${apos}tag-r3${apos}:
357 Right #3
358 Common #2
359 Common #1
362 test_might_fail git config --unset-all merge.log &&
363 git config merge.summary yes &&
365 git checkout master &&
366 test_tick &&
367 git fetch . tag tag-r3 &&
369 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
370 test_cmp expected actual
373 test_expect_success 'merge-msg two tags' '
374 cat >expected <<-EOF &&
375 Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos}
377 * tag ${apos}tag-r3${apos}:
378 Right #3
379 Common #2
380 Common #1
382 * tag ${apos}tag-l5${apos}:
383 Left #5
384 Left #4
385 Left #3
386 Common #2
387 Common #1
390 test_might_fail git config --unset-all merge.log &&
391 git config merge.summary yes &&
393 git checkout master &&
394 test_tick &&
395 git fetch . tag tag-r3 tag tag-l5 &&
397 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
398 test_cmp expected actual
401 test_expect_success 'merge-msg tag and branch' '
402 cat >expected <<-EOF &&
403 Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos}
405 * tag ${apos}tag-r3${apos}:
406 Right #3
407 Common #2
408 Common #1
410 * left:
411 Left #5
412 Left #4
413 Left #3
414 Common #2
415 Common #1
418 test_might_fail git config --unset-all merge.log &&
419 git config merge.summary yes &&
421 git checkout master &&
422 test_tick &&
423 git fetch . tag tag-r3 left &&
425 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
426 test_cmp expected actual
429 test_expect_success 'merge-msg lots of commits' '
431 cat <<-EOF &&
432 Merge branch ${apos}long${apos}
434 * long: (35 commits)
437 i=29 &&
438 while test $i -gt 9
440 echo " $i" &&
441 i=$(($i-1))
442 done &&
443 echo " ..."
444 } >expected &&
446 git checkout master &&
447 test_tick &&
448 git fetch . long &&
450 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
451 test_cmp expected actual
454 test_done