t6200-fmt-merge-msg: Exercise 'merge.log' to configure shortlog length
[git/jrn.git] / t / t6200-fmt-merge-msg.sh
blob9b600a8717aaafca9fb8308c461e441af83e367b
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 'fmt-merge-msg -m' '
181 echo "Sync with left" >expected &&
182 cat >expected.log <<-EOF &&
183 Sync with left
185 * ${apos}left${apos} of $(pwd):
186 Left #5
187 Left #4
188 Left #3
189 Common #2
190 Common #1
193 test_might_fail git config --unset merge.log &&
194 test_might_fail git config --unset merge.summary &&
195 git checkout master &&
196 git fetch "$(pwd)" left &&
197 git fmt-merge-msg -m "Sync with left" <.git/FETCH_HEAD >actual &&
198 git fmt-merge-msg --log -m "Sync with left" \
199 <.git/FETCH_HEAD >actual.log &&
200 git config merge.log true &&
201 git fmt-merge-msg -m "Sync with left" \
202 <.git/FETCH_HEAD >actual.log-config &&
203 git fmt-merge-msg --no-log -m "Sync with left" \
204 <.git/FETCH_HEAD >actual.nolog &&
206 test_cmp expected actual &&
207 test_cmp expected.log actual.log &&
208 test_cmp expected.log actual.log-config &&
209 test_cmp expected actual.nolog
212 test_expect_success 'setup: expected shortlog for two branches' '
213 cat >expected <<-EOF
214 Merge branches ${apos}left${apos} and ${apos}right${apos}
216 * left:
217 Left #5
218 Left #4
219 Left #3
220 Common #2
221 Common #1
223 * right:
224 Right #5
225 Right #4
226 Right #3
227 Common #2
228 Common #1
232 test_expect_success 'shortlog for two branches' '
233 git config merge.log true &&
234 test_might_fail git config --unset-all merge.summary &&
235 git checkout master &&
236 test_tick &&
237 git fetch . left right &&
238 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
240 test_might_fail git config --unset-all merge.log &&
241 git config merge.summary true &&
242 git checkout master &&
243 test_tick &&
244 git fetch . left right &&
245 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
247 git config merge.log yes &&
248 test_might_fail git config --unset-all merge.summary &&
249 git checkout master &&
250 test_tick &&
251 git fetch . left right &&
252 git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
254 test_might_fail git config --unset-all merge.log &&
255 git config merge.summary yes &&
256 git checkout master &&
257 test_tick &&
258 git fetch . left right &&
259 git fmt-merge-msg <.git/FETCH_HEAD >actual4 &&
261 test_cmp expected actual1 &&
262 test_cmp expected actual2 &&
263 test_cmp expected actual3 &&
264 test_cmp expected actual4
267 test_expect_success 'merge-msg -F' '
268 test_might_fail git config --unset-all merge.log &&
269 git config merge.summary yes &&
270 git checkout master &&
271 test_tick &&
272 git fetch . left right &&
273 git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
274 test_cmp expected actual
277 test_expect_success 'merge-msg -F in subdirectory' '
278 test_might_fail git config --unset-all merge.log &&
279 git config merge.summary yes &&
280 git checkout master &&
281 test_tick &&
282 git fetch . left right &&
283 mkdir sub &&
284 cp .git/FETCH_HEAD sub/FETCH_HEAD &&
286 cd sub &&
287 git fmt-merge-msg -F FETCH_HEAD >../actual
288 ) &&
289 test_cmp expected actual
292 test_expect_success 'merge-msg with nothing to merge' '
293 test_might_fail git config --unset-all merge.log &&
294 git config merge.summary yes &&
296 >empty &&
299 cd remote &&
300 git checkout -b unrelated &&
301 test_tick &&
302 git fetch origin &&
303 git fmt-merge-msg <.git/FETCH_HEAD >../actual
304 ) &&
306 test_cmp empty actual
309 test_expect_success 'merge-msg tag' '
310 cat >expected <<-EOF &&
311 Merge tag ${apos}tag-r3${apos}
313 * tag ${apos}tag-r3${apos}:
314 Right #3
315 Common #2
316 Common #1
319 test_might_fail git config --unset-all merge.log &&
320 git config merge.summary yes &&
322 git checkout master &&
323 test_tick &&
324 git fetch . tag tag-r3 &&
326 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
327 test_cmp expected actual
330 test_expect_success 'merge-msg two tags' '
331 cat >expected <<-EOF &&
332 Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos}
334 * tag ${apos}tag-r3${apos}:
335 Right #3
336 Common #2
337 Common #1
339 * tag ${apos}tag-l5${apos}:
340 Left #5
341 Left #4
342 Left #3
343 Common #2
344 Common #1
347 test_might_fail git config --unset-all merge.log &&
348 git config merge.summary yes &&
350 git checkout master &&
351 test_tick &&
352 git fetch . tag tag-r3 tag tag-l5 &&
354 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
355 test_cmp expected actual
358 test_expect_success 'merge-msg tag and branch' '
359 cat >expected <<-EOF &&
360 Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos}
362 * tag ${apos}tag-r3${apos}:
363 Right #3
364 Common #2
365 Common #1
367 * left:
368 Left #5
369 Left #4
370 Left #3
371 Common #2
372 Common #1
375 test_might_fail git config --unset-all merge.log &&
376 git config merge.summary yes &&
378 git checkout master &&
379 test_tick &&
380 git fetch . tag tag-r3 left &&
382 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
383 test_cmp expected actual
386 test_expect_success 'merge-msg lots of commits' '
388 cat <<-EOF &&
389 Merge branch ${apos}long${apos}
391 * long: (35 commits)
394 i=29 &&
395 while test $i -gt 9
397 echo " $i" &&
398 i=$(($i-1))
399 done &&
400 echo " ..."
401 } >expected &&
403 git checkout master &&
404 test_tick &&
405 git fetch . long &&
407 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
408 test_cmp expected actual
411 test_done