]> asedeno.scripts.mit.edu Git - git.git/blob - t/t6200-fmt-merge-msg.sh
b24c5bfd7a300500466401e874a5039f6ddf80ea
[git.git] / t / t6200-fmt-merge-msg.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2006, Junio C Hamano
4 #
5
6 test_description='fmt-merge-msg test'
7
8 . ./test-lib.sh
9
10 test_expect_success setup '
11         echo one >one &&
12         git add one &&
13         test_tick &&
14         git commit -m "Initial" &&
15
16         git clone . remote &&
17
18         echo uno >one &&
19         echo dos >two &&
20         git add two &&
21         test_tick &&
22         git commit -a -m "Second" &&
23
24         git checkout -b left &&
25
26         echo "c1" >one &&
27         test_tick &&
28         git commit -a -m "Common #1" &&
29
30         echo "c2" >one &&
31         test_tick &&
32         git commit -a -m "Common #2" &&
33
34         git branch right &&
35
36         echo "l3" >two &&
37         test_tick &&
38         git commit -a -m "Left #3" &&
39
40         echo "l4" >two &&
41         test_tick &&
42         git commit -a -m "Left #4" &&
43
44         echo "l5" >two &&
45         test_tick &&
46         git commit -a -m "Left #5" &&
47         git tag tag-l5 &&
48
49         git checkout right &&
50
51         echo "r3" >three &&
52         git add three &&
53         test_tick &&
54         git commit -a -m "Right #3" &&
55         git tag tag-r3 &&
56
57         echo "r4" >three &&
58         test_tick &&
59         git commit -a -m "Right #4" &&
60
61         echo "r5" >three &&
62         test_tick &&
63         git commit -a -m "Right #5" &&
64
65         git show-branch
66 '
67
68 cat >expected <<\EOF
69 Merge branch 'left'
70 EOF
71
72 test_expect_success 'merge-msg test #1' '
73
74         git checkout master &&
75         git fetch . left &&
76
77         git fmt-merge-msg <.git/FETCH_HEAD >actual &&
78         test_cmp expected actual
79 '
80
81 cat >expected <<EOF
82 Merge branch 'left' of $(pwd)
83 EOF
84
85 test_expect_success 'merge-msg test #2' '
86
87         git checkout master &&
88         git fetch "$(pwd)" left &&
89
90         git fmt-merge-msg <.git/FETCH_HEAD >actual &&
91         test_cmp expected actual
92 '
93
94 cat >expected <<\EOF
95 Merge branch 'left'
96
97 * left:
98   Left #5
99   Left #4
100   Left #3
101   Common #2
102   Common #1
103 EOF
104
105 test_expect_success 'merge-msg test #3-1' '
106
107         git config --unset-all merge.log
108         git config --unset-all merge.summary
109         git config merge.log true &&
110
111         git checkout master &&
112         test_tick &&
113         git fetch . left &&
114
115         git fmt-merge-msg <.git/FETCH_HEAD >actual &&
116         test_cmp expected actual
117 '
118
119 test_expect_success 'merge-msg test #3-2' '
120
121         git config --unset-all merge.log
122         git config --unset-all merge.summary
123         git config merge.summary true &&
124
125         git checkout master &&
126         test_tick &&
127         git fetch . left &&
128
129         git fmt-merge-msg <.git/FETCH_HEAD >actual &&
130         test_cmp expected actual
131 '
132
133 cat >expected <<\EOF
134 Merge branches 'left' and 'right'
135
136 * left:
137   Left #5
138   Left #4
139   Left #3
140   Common #2
141   Common #1
142
143 * right:
144   Right #5
145   Right #4
146   Right #3
147   Common #2
148   Common #1
149 EOF
150
151 test_expect_success 'merge-msg test #4-1' '
152
153         git config --unset-all merge.log
154         git config --unset-all merge.summary
155         git config merge.log true &&
156
157         git checkout master &&
158         test_tick &&
159         git fetch . left right &&
160
161         git fmt-merge-msg <.git/FETCH_HEAD >actual &&
162         test_cmp expected actual
163 '
164
165 test_expect_success 'merge-msg test #4-2' '
166
167         git config --unset-all merge.log
168         git config --unset-all merge.summary
169         git config merge.summary true &&
170
171         git checkout master &&
172         test_tick &&
173         git fetch . left right &&
174
175         git fmt-merge-msg <.git/FETCH_HEAD >actual &&
176         test_cmp expected actual
177 '
178
179 test_expect_success 'merge-msg test #5-1' '
180
181         git config --unset-all merge.log
182         git config --unset-all merge.summary
183         git config merge.log yes &&
184
185         git checkout master &&
186         test_tick &&
187         git fetch . left right &&
188
189         git fmt-merge-msg <.git/FETCH_HEAD >actual &&
190         test_cmp expected actual
191 '
192
193 test_expect_success 'merge-msg test #5-2' '
194
195         git config --unset-all merge.log
196         git config --unset-all merge.summary
197         git config merge.summary yes &&
198
199         git checkout master &&
200         test_tick &&
201         git fetch . left right &&
202
203         git fmt-merge-msg <.git/FETCH_HEAD >actual &&
204         test_cmp expected actual
205 '
206
207 test_expect_success 'merge-msg -F' '
208
209         git config --unset-all merge.log
210         git config --unset-all merge.summary
211         git config merge.summary yes &&
212
213         git checkout master &&
214         test_tick &&
215         git fetch . left right &&
216
217         git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
218         test_cmp expected actual
219 '
220
221 test_expect_success 'merge-msg -F in subdirectory' '
222
223         git config --unset-all merge.log
224         git config --unset-all merge.summary
225         git config merge.summary yes &&
226
227         git checkout master &&
228         test_tick &&
229         git fetch . left right &&
230         mkdir sub &&
231         cp .git/FETCH_HEAD sub/FETCH_HEAD &&
232         (
233                 cd sub &&
234                 git fmt-merge-msg -F FETCH_HEAD >../actual
235         ) &&
236         test_cmp expected actual
237 '
238
239 test_expect_success 'merge-msg with nothing to merge' '
240
241         git config --unset-all merge.log
242         git config --unset-all merge.summary
243         git config merge.summary yes &&
244
245         (
246                 cd remote &&
247                 git checkout -b unrelated &&
248                 test_tick &&
249                 git fetch origin &&
250                 git fmt-merge-msg <.git/FETCH_HEAD >../actual
251         ) &&
252
253         test_cmp /dev/null actual
254 '
255
256 test_done