Allow core.askpass to override SSH_ASKPASS.
[git/gitweb.git] / t / t6200-fmt-merge-msg.sh
blob42f8ece0978f38e10200a52ce8cf1952cf13ecbd
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
76 cat >expected <<\EOF
77 Merge branch 'left'
78 EOF
80 test_expect_success 'merge-msg test #1' '
82 git checkout master &&
83 git fetch . left &&
85 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
86 test_cmp expected actual
89 cat >expected <<EOF
90 Merge branch 'left' of $(pwd)
91 EOF
93 test_expect_success 'merge-msg test #2' '
95 git checkout master &&
96 git fetch "$(pwd)" left &&
98 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
99 test_cmp expected actual
102 cat >expected <<\EOF
103 Merge branch 'left'
105 * left:
106 Left #5
107 Left #4
108 Left #3
109 Common #2
110 Common #1
113 test_expect_success 'merge-msg test #3-1' '
115 git config --unset-all merge.log
116 git config --unset-all merge.summary
117 git config merge.log true &&
119 git checkout master &&
120 test_tick &&
121 git fetch . left &&
123 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
124 test_cmp expected actual
127 test_expect_success 'merge-msg test #3-2' '
129 git config --unset-all merge.log
130 git config --unset-all merge.summary
131 git config merge.summary true &&
133 git checkout master &&
134 test_tick &&
135 git fetch . left &&
137 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
138 test_cmp expected actual
141 cat >expected <<\EOF
142 Merge branches 'left' and 'right'
144 * left:
145 Left #5
146 Left #4
147 Left #3
148 Common #2
149 Common #1
151 * right:
152 Right #5
153 Right #4
154 Right #3
155 Common #2
156 Common #1
159 test_expect_success 'merge-msg test #4-1' '
161 git config --unset-all merge.log
162 git config --unset-all merge.summary
163 git config merge.log true &&
165 git checkout master &&
166 test_tick &&
167 git fetch . left right &&
169 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
170 test_cmp expected actual
173 test_expect_success 'merge-msg test #4-2' '
175 git config --unset-all merge.log
176 git config --unset-all merge.summary
177 git config merge.summary true &&
179 git checkout master &&
180 test_tick &&
181 git fetch . left right &&
183 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
184 test_cmp expected actual
187 test_expect_success 'merge-msg test #5-1' '
189 git config --unset-all merge.log
190 git config --unset-all merge.summary
191 git config merge.log yes &&
193 git checkout master &&
194 test_tick &&
195 git fetch . left right &&
197 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
198 test_cmp expected actual
201 test_expect_success 'merge-msg test #5-2' '
203 git config --unset-all merge.log
204 git config --unset-all merge.summary
205 git config merge.summary yes &&
207 git checkout master &&
208 test_tick &&
209 git fetch . left right &&
211 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
212 test_cmp expected actual
215 test_expect_success 'merge-msg -F' '
217 git config --unset-all merge.log
218 git config --unset-all merge.summary
219 git config merge.summary yes &&
221 git checkout master &&
222 test_tick &&
223 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' '
231 git config --unset-all merge.log
232 git config --unset-all merge.summary
233 git config merge.summary yes &&
235 git checkout master &&
236 test_tick &&
237 git fetch . left right &&
238 mkdir sub &&
239 cp .git/FETCH_HEAD sub/FETCH_HEAD &&
241 cd sub &&
242 git fmt-merge-msg -F FETCH_HEAD >../actual
243 ) &&
244 test_cmp expected actual
247 test_expect_success 'merge-msg with nothing to merge' '
249 git config --unset-all merge.log
250 git config --unset-all merge.summary
251 git config merge.summary yes &&
254 cd remote &&
255 git checkout -b unrelated &&
256 test_tick &&
257 git fetch origin &&
258 git fmt-merge-msg <.git/FETCH_HEAD >../actual
259 ) &&
261 test_cmp /dev/null actual
264 cat >expected <<\EOF
265 Merge tag 'tag-r3'
267 * tag 'tag-r3':
268 Right #3
269 Common #2
270 Common #1
273 test_expect_success 'merge-msg tag' '
275 git config --unset-all merge.log
276 git config --unset-all merge.summary
277 git config merge.summary yes &&
279 git checkout master &&
280 test_tick &&
281 git fetch . tag tag-r3 &&
283 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
284 test_cmp expected actual
287 cat >expected <<\EOF
288 Merge tags 'tag-r3' and 'tag-l5'
290 * tag 'tag-r3':
291 Right #3
292 Common #2
293 Common #1
295 * tag 'tag-l5':
296 Left #5
297 Left #4
298 Left #3
299 Common #2
300 Common #1
303 test_expect_success 'merge-msg two tags' '
305 git config --unset-all merge.log
306 git config --unset-all merge.summary
307 git config merge.summary yes &&
309 git checkout master &&
310 test_tick &&
311 git fetch . tag tag-r3 tag tag-l5 &&
313 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
314 test_cmp expected actual
317 cat >expected <<\EOF
318 Merge branch 'left', tag 'tag-r3'
320 * tag 'tag-r3':
321 Right #3
322 Common #2
323 Common #1
325 * left:
326 Left #5
327 Left #4
328 Left #3
329 Common #2
330 Common #1
333 test_expect_success 'merge-msg tag and branch' '
335 git config --unset-all merge.log
336 git config --unset-all merge.summary
337 git config merge.summary yes &&
339 git checkout master &&
340 test_tick &&
341 git fetch . tag tag-r3 left &&
343 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
344 test_cmp expected actual
347 cat >expected <<\EOF
348 Merge branch 'long'
350 * long: (35 commits)
353 test_expect_success 'merge-msg lots of commits' '
355 git checkout master &&
356 test_tick &&
357 git fetch . long &&
359 i=29 &&
360 while test $i -gt 9
362 echo " $i" &&
363 i=$(($i-1))
364 done >>expected &&
365 echo " ..." >>expected
367 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
368 test_cmp expected actual
371 test_done