parse-options: do not infer PARSE_OPT_NOARG from option type
[git/srabbelier.git] / t / t6200-fmt-merge-msg.sh
blob71f6cad3c2b8e8ed0b16d292f4922760901702ef
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 'fmt-merge-msg -m' '
133 echo "Sync with left" >expected &&
134 cat >expected.log <<-EOF &&
135 Sync with left
137 * ${apos}left${apos} of $(pwd):
138 Left #5
139 Left #4
140 Left #3
141 Common #2
142 Common #1
145 test_might_fail git config --unset merge.log &&
146 test_might_fail git config --unset merge.summary &&
147 git checkout master &&
148 git fetch "$(pwd)" left &&
149 git fmt-merge-msg -m "Sync with left" <.git/FETCH_HEAD >actual &&
150 git fmt-merge-msg --log -m "Sync with left" \
151 <.git/FETCH_HEAD >actual.log &&
152 git config merge.log true &&
153 git fmt-merge-msg -m "Sync with left" \
154 <.git/FETCH_HEAD >actual.log-config &&
155 git fmt-merge-msg --no-log -m "Sync with left" \
156 <.git/FETCH_HEAD >actual.nolog &&
158 test_cmp expected actual &&
159 test_cmp expected.log actual.log &&
160 test_cmp expected.log actual.log-config &&
161 test_cmp expected actual.nolog
164 test_expect_success 'setup: expected shortlog for two branches' '
165 cat >expected <<-EOF
166 Merge branches ${apos}left${apos} and ${apos}right${apos}
168 * left:
169 Left #5
170 Left #4
171 Left #3
172 Common #2
173 Common #1
175 * right:
176 Right #5
177 Right #4
178 Right #3
179 Common #2
180 Common #1
184 test_expect_success 'shortlog for two branches' '
185 git config merge.log true &&
186 test_might_fail git config --unset-all merge.summary &&
187 git checkout master &&
188 test_tick &&
189 git fetch . left right &&
190 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
192 test_might_fail git config --unset-all merge.log &&
193 git config merge.summary true &&
194 git checkout master &&
195 test_tick &&
196 git fetch . left right &&
197 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
199 git config merge.log yes &&
200 test_might_fail git config --unset-all merge.summary &&
201 git checkout master &&
202 test_tick &&
203 git fetch . left right &&
204 git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
206 test_might_fail git config --unset-all merge.log &&
207 git config merge.summary yes &&
208 git checkout master &&
209 test_tick &&
210 git fetch . left right &&
211 git fmt-merge-msg <.git/FETCH_HEAD >actual4 &&
213 test_cmp expected actual1 &&
214 test_cmp expected actual2 &&
215 test_cmp expected actual3 &&
216 test_cmp expected actual4
219 test_expect_success 'merge-msg -F' '
220 test_might_fail git config --unset-all merge.log &&
221 git config merge.summary yes &&
222 git checkout master &&
223 test_tick &&
224 git fetch . left right &&
225 git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
226 test_cmp expected actual
229 test_expect_success 'merge-msg -F in subdirectory' '
230 test_might_fail git config --unset-all merge.log &&
231 git config merge.summary yes &&
232 git checkout master &&
233 test_tick &&
234 git fetch . left right &&
235 mkdir sub &&
236 cp .git/FETCH_HEAD sub/FETCH_HEAD &&
238 cd sub &&
239 git fmt-merge-msg -F FETCH_HEAD >../actual
240 ) &&
241 test_cmp expected actual
244 test_expect_success 'merge-msg with nothing to merge' '
245 test_might_fail git config --unset-all merge.log &&
246 git config merge.summary yes &&
248 >empty &&
251 cd remote &&
252 git checkout -b unrelated &&
253 test_tick &&
254 git fetch origin &&
255 git fmt-merge-msg <.git/FETCH_HEAD >../actual
256 ) &&
258 test_cmp empty actual
261 test_expect_success 'merge-msg tag' '
262 cat >expected <<-EOF &&
263 Merge tag ${apos}tag-r3${apos}
265 * tag ${apos}tag-r3${apos}:
266 Right #3
267 Common #2
268 Common #1
271 test_might_fail git config --unset-all merge.log &&
272 git config merge.summary yes &&
274 git checkout master &&
275 test_tick &&
276 git fetch . tag tag-r3 &&
278 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
279 test_cmp expected actual
282 test_expect_success 'merge-msg two tags' '
283 cat >expected <<-EOF &&
284 Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos}
286 * tag ${apos}tag-r3${apos}:
287 Right #3
288 Common #2
289 Common #1
291 * tag ${apos}tag-l5${apos}:
292 Left #5
293 Left #4
294 Left #3
295 Common #2
296 Common #1
299 test_might_fail git config --unset-all merge.log &&
300 git config merge.summary yes &&
302 git checkout master &&
303 test_tick &&
304 git fetch . tag tag-r3 tag tag-l5 &&
306 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
307 test_cmp expected actual
310 test_expect_success 'merge-msg tag and branch' '
311 cat >expected <<-EOF &&
312 Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos}
314 * tag ${apos}tag-r3${apos}:
315 Right #3
316 Common #2
317 Common #1
319 * left:
320 Left #5
321 Left #4
322 Left #3
323 Common #2
324 Common #1
327 test_might_fail git config --unset-all merge.log &&
328 git config merge.summary yes &&
330 git checkout master &&
331 test_tick &&
332 git fetch . tag tag-r3 left &&
334 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
335 test_cmp expected actual
338 test_expect_success 'merge-msg lots of commits' '
340 cat <<-EOF &&
341 Merge branch ${apos}long${apos}
343 * long: (35 commits)
346 i=29 &&
347 while test $i -gt 9
349 echo " $i" &&
350 i=$(($i-1))
351 done &&
352 echo " ..."
353 } >expected &&
355 git checkout master &&
356 test_tick &&
357 git fetch . long &&
359 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
360 test_cmp expected actual
363 test_done