]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6200-fmt-merge-msg.sh
status: fix bug with missing --ignore files
[thirdparty/git.git] / t / t6200-fmt-merge-msg.sh
CommitLineData
30a95f30
JH
1#!/bin/sh
2#
3# Copyright (c) 2006, Junio C Hamano
4#
5
6test_description='fmt-merge-msg test'
7
8. ./test-lib.sh
9
30a95f30
JH
10test_expect_success setup '
11 echo one >one &&
12 git add one &&
6183a6ad 13 test_tick &&
30a95f30
JH
14 git commit -m "Initial" &&
15
419fe5bc
SB
16 git clone . remote &&
17
30a95f30
JH
18 echo uno >one &&
19 echo dos >two &&
20 git add two &&
6183a6ad 21 test_tick &&
30a95f30
JH
22 git commit -a -m "Second" &&
23
24 git checkout -b left &&
25
6183a6ad
SB
26 echo "c1" >one &&
27 test_tick &&
30a95f30
JH
28 git commit -a -m "Common #1" &&
29
6183a6ad
SB
30 echo "c2" >one &&
31 test_tick &&
30a95f30
JH
32 git commit -a -m "Common #2" &&
33
34 git branch right &&
35
6183a6ad
SB
36 echo "l3" >two &&
37 test_tick &&
30a95f30
JH
38 git commit -a -m "Left #3" &&
39
6183a6ad
SB
40 echo "l4" >two &&
41 test_tick &&
30a95f30
JH
42 git commit -a -m "Left #4" &&
43
6183a6ad
SB
44 echo "l5" >two &&
45 test_tick &&
30a95f30 46 git commit -a -m "Left #5" &&
6183a6ad 47 git tag tag-l5 &&
30a95f30
JH
48
49 git checkout right &&
50
6183a6ad 51 echo "r3" >three &&
30a95f30 52 git add three &&
6183a6ad 53 test_tick &&
30a95f30 54 git commit -a -m "Right #3" &&
6183a6ad 55 git tag tag-r3 &&
30a95f30 56
6183a6ad
SB
57 echo "r4" >three &&
58 test_tick &&
30a95f30
JH
59 git commit -a -m "Right #4" &&
60
6183a6ad
SB
61 echo "r5" >three &&
62 test_tick &&
30a95f30
JH
63 git commit -a -m "Right #5" &&
64
6d6f6e68
SB
65 git checkout -b long &&
66 i=0 &&
67 while test $i -lt 30
68 do
69 test_commit $i one &&
70 i=$(($i+1))
71 done &&
72
30a95f30
JH
73 git show-branch
74'
75
76cat >expected <<\EOF
77Merge branch 'left'
78EOF
79
80test_expect_success 'merge-msg test #1' '
81
82 git checkout master &&
83 git fetch . left &&
84
85 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
3af82863 86 test_cmp expected actual
30a95f30
JH
87'
88
4a7aaccd 89cat >expected <<EOF
4114156a 90Merge branch 'left' of $(pwd)
30a95f30
JH
91EOF
92
93test_expect_success 'merge-msg test #2' '
94
95 git checkout master &&
4114156a 96 git fetch "$(pwd)" left &&
30a95f30
JH
97
98 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
3af82863 99 test_cmp expected actual
30a95f30
JH
100'
101
102cat >expected <<\EOF
103Merge branch 'left'
104
105* left:
106 Left #5
107 Left #4
108 Left #3
109 Common #2
110 Common #1
111EOF
112
6cd9cfef 113test_expect_success 'merge-msg test #3-1' '
30a95f30 114
6cd9cfef
SG
115 git config --unset-all merge.log
116 git config --unset-all merge.summary
117 git config merge.log true &&
118
119 git checkout master &&
6183a6ad 120 test_tick &&
6cd9cfef
SG
121 git fetch . left &&
122
123 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
3af82863 124 test_cmp expected actual
6cd9cfef
SG
125'
126
127test_expect_success 'merge-msg test #3-2' '
128
129 git config --unset-all merge.log
130 git config --unset-all merge.summary
e0d10e1c 131 git config merge.summary true &&
30a95f30
JH
132
133 git checkout master &&
6183a6ad 134 test_tick &&
30a95f30
JH
135 git fetch . left &&
136
137 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
3af82863 138 test_cmp expected actual
30a95f30
JH
139'
140
141cat >expected <<\EOF
142Merge branches 'left' and 'right'
143
144* left:
145 Left #5
146 Left #4
147 Left #3
148 Common #2
149 Common #1
150
151* right:
152 Right #5
153 Right #4
154 Right #3
155 Common #2
156 Common #1
157EOF
158
6cd9cfef
SG
159test_expect_success 'merge-msg test #4-1' '
160
161 git config --unset-all merge.log
162 git config --unset-all merge.summary
163 git config merge.log true &&
164
165 git checkout master &&
6183a6ad 166 test_tick &&
6cd9cfef
SG
167 git fetch . left right &&
168
169 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
3af82863 170 test_cmp expected actual
6cd9cfef
SG
171'
172
173test_expect_success 'merge-msg test #4-2' '
30a95f30 174
6cd9cfef
SG
175 git config --unset-all merge.log
176 git config --unset-all merge.summary
e0d10e1c 177 git config merge.summary true &&
30a95f30
JH
178
179 git checkout master &&
6183a6ad 180 test_tick &&
30a95f30
JH
181 git fetch . left right &&
182
183 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
3af82863 184 test_cmp expected actual
30a95f30
JH
185'
186
6cd9cfef
SG
187test_expect_success 'merge-msg test #5-1' '
188
189 git config --unset-all merge.log
190 git config --unset-all merge.summary
191 git config merge.log yes &&
192
193 git checkout master &&
6183a6ad 194 test_tick &&
6cd9cfef
SG
195 git fetch . left right &&
196
197 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
3af82863 198 test_cmp expected actual
6cd9cfef
SG
199'
200
201test_expect_success 'merge-msg test #5-2' '
30a95f30 202
6cd9cfef
SG
203 git config --unset-all merge.log
204 git config --unset-all merge.summary
e0d10e1c 205 git config merge.summary yes &&
30a95f30
JH
206
207 git checkout master &&
6183a6ad 208 test_tick &&
30a95f30
JH
209 git fetch . left right &&
210
211 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
3af82863 212 test_cmp expected actual
30a95f30
JH
213'
214
4c8d4c14
SB
215test_expect_success 'merge-msg -F' '
216
217 git config --unset-all merge.log
218 git config --unset-all merge.summary
219 git config merge.summary yes &&
220
221 git checkout master &&
6183a6ad 222 test_tick &&
4c8d4c14
SB
223 git fetch . left right &&
224
225 git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
226 test_cmp expected actual
227'
228
229test_expect_success 'merge-msg -F in subdirectory' '
230
231 git config --unset-all merge.log
232 git config --unset-all merge.summary
233 git config merge.summary yes &&
234
235 git checkout master &&
6183a6ad 236 test_tick &&
4c8d4c14
SB
237 git fetch . left right &&
238 mkdir sub &&
239 cp .git/FETCH_HEAD sub/FETCH_HEAD &&
240 (
241 cd sub &&
242 git fmt-merge-msg -F FETCH_HEAD >../actual
243 ) &&
244 test_cmp expected actual
245'
246
419fe5bc
SB
247test_expect_success 'merge-msg with nothing to merge' '
248
249 git config --unset-all merge.log
250 git config --unset-all merge.summary
251 git config merge.summary yes &&
252
253 (
254 cd remote &&
255 git checkout -b unrelated &&
6183a6ad 256 test_tick &&
419fe5bc
SB
257 git fetch origin &&
258 git fmt-merge-msg <.git/FETCH_HEAD >../actual
259 ) &&
260
261 test_cmp /dev/null actual
262'
263
6d6f6e68
SB
264cat >expected <<\EOF
265Merge tag 'tag-r3'
266
267* tag 'tag-r3':
268 Right #3
269 Common #2
270 Common #1
271EOF
272
273test_expect_success 'merge-msg tag' '
274
275 git config --unset-all merge.log
276 git config --unset-all merge.summary
277 git config merge.summary yes &&
278
279 git checkout master &&
280 test_tick &&
281 git fetch . tag tag-r3 &&
282
283 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
284 test_cmp expected actual
285'
286
287cat >expected <<\EOF
288Merge tags 'tag-r3' and 'tag-l5'
289
290* tag 'tag-r3':
291 Right #3
292 Common #2
293 Common #1
294
295* tag 'tag-l5':
296 Left #5
297 Left #4
298 Left #3
299 Common #2
300 Common #1
301EOF
302
303test_expect_success 'merge-msg two tags' '
304
305 git config --unset-all merge.log
306 git config --unset-all merge.summary
307 git config merge.summary yes &&
308
309 git checkout master &&
310 test_tick &&
311 git fetch . tag tag-r3 tag tag-l5 &&
312
313 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
314 test_cmp expected actual
315'
316
317cat >expected <<\EOF
318Merge branch 'left', tag 'tag-r3'
319
320* tag 'tag-r3':
321 Right #3
322 Common #2
323 Common #1
324
325* left:
326 Left #5
327 Left #4
328 Left #3
329 Common #2
330 Common #1
331EOF
332
333test_expect_success 'merge-msg tag and branch' '
334
335 git config --unset-all merge.log
336 git config --unset-all merge.summary
337 git config merge.summary yes &&
338
339 git checkout master &&
340 test_tick &&
341 git fetch . tag tag-r3 left &&
342
343 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
344 test_cmp expected actual
345'
346
347cat >expected <<\EOF
348Merge branch 'long'
349
350* long: (35 commits)
351EOF
352
353test_expect_success 'merge-msg lots of commits' '
354
355 git checkout master &&
356 test_tick &&
357 git fetch . long &&
358
359 i=29 &&
360 while test $i -gt 9
361 do
362 echo " $i" &&
363 i=$(($i-1))
364 done >>expected &&
365 echo " ..." >>expected
366
367 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
368 test_cmp expected actual
369'
370
30a95f30 371test_done