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