3 # Copyright (c) 2006, Junio C Hamano
6 test_description='fmt-merge-msg test'
10 test_expect_success setup '
14 git commit -m "Initial" &&
22 git commit -a -m "Second" &&
24 git checkout -b left &&
28 git commit -a -m "Common #1" &&
32 git commit -a -m "Common #2" &&
38 git commit -a -m "Left #3" &&
42 git commit -a -m "Left #4" &&
46 git commit -a -m "Left #5" &&
54 git commit -a -m "Right #3" &&
59 git commit -a -m "Right #4" &&
63 git commit -a -m "Right #5" &&
65 git checkout -b long &&
78 test_expect_success 'message for merging local branch' '
79 echo "Merge branch ${apos}left${apos}" >expected &&
81 git checkout master &&
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}
110 git config merge.log true &&
111 test_might_fail git config --unset-all merge.summary &&
113 git checkout master &&
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 &&
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 &&
143 test_expect_success 'merge.log=3 limits shortlog length' '
144 cat >expected <<-EOF &&
145 Merge branch ${apos}left${apos}
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}
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}
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}
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 &&
228 * ${apos}left${apos} of $(pwd):
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' '
257 Merge branches ${apos}left${apos} and ${apos}right${apos}
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 &&
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 &&
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 &&
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 &&
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 &&
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 &&
325 git fetch . left right &&
327 cp .git/FETCH_HEAD sub/FETCH_HEAD &&
330 git fmt-merge-msg -F FETCH_HEAD >../actual
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 &&
343 git checkout -b unrelated &&
346 git fmt-merge-msg <.git/FETCH_HEAD >../actual
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}:
362 test_might_fail git config --unset-all merge.log &&
363 git config merge.summary yes &&
365 git checkout master &&
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}:
382 * tag ${apos}tag-l5${apos}:
390 test_might_fail git config --unset-all merge.log &&
391 git config merge.summary yes &&
393 git checkout master &&
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}:
418 test_might_fail git config --unset-all merge.log &&
419 git config merge.summary yes &&
421 git checkout master &&
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' '
432 Merge branch ${apos}long${apos}
446 git checkout master &&
450 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
451 test_cmp expected actual