t6018-rev-list-glob: fix 'empty stdin' test
[git/git.git] / t / t6018-rev-list-glob.sh
CommitLineData
d08bae7e
IL
1#!/bin/sh
2
3test_description='rev-list/rev-parse --glob'
4
5. ./test-lib.sh
6
7commit () {
8 test_tick &&
9 echo $1 > foo &&
10 git add foo &&
11 git commit -m "$1"
12}
13
14compare () {
15 # Split arguments on whitespace.
16 git $1 $2 >expected &&
17 git $1 $3 >actual &&
18 test_cmp expected actual
19}
20
21test_expect_success 'setup' '
22
23 commit master &&
24 git checkout -b subspace/one master &&
25 commit one &&
26 git checkout -b subspace/two master &&
27 commit two &&
28 git checkout -b subspace-x master &&
29 commit subspace-x &&
30 git checkout -b other/three master &&
31 commit three &&
32 git checkout -b someref master &&
33 commit some &&
34 git checkout master &&
b09fe971
IL
35 commit master2 &&
36 git tag foo/bar master &&
52663475
MG
37 commit master3 &&
38 git update-ref refs/remotes/foo/baz master &&
39 commit master4
d08bae7e
IL
40'
41
42test_expect_success 'rev-parse --glob=refs/heads/subspace/*' '
43
44 compare rev-parse "subspace/one subspace/two" "--glob=refs/heads/subspace/*"
45
46'
47
48test_expect_success 'rev-parse --glob=heads/subspace/*' '
49
50 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace/*"
51
52'
53
54test_expect_success 'rev-parse --glob=refs/heads/subspace/' '
55
56 compare rev-parse "subspace/one subspace/two" "--glob=refs/heads/subspace/"
57
58'
59
60test_expect_success 'rev-parse --glob=heads/subspace/' '
61
62 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace/"
63
64'
65
66test_expect_success 'rev-parse --glob=heads/subspace' '
67
68 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace"
69
70'
71
0fc63ec4
JN
72test_expect_failure 'rev-parse accepts --glob as detached option' '
73
74 compare rev-parse "subspace/one subspace/two" "--glob heads/subspace"
75
76'
77
78test_expect_failure 'rev-parse is not confused by option-like glob' '
79
80 compare rev-parse "master" "--glob --symbolic master"
81
82'
83
b09fe971
IL
84test_expect_success 'rev-parse --branches=subspace/*' '
85
86 compare rev-parse "subspace/one subspace/two" "--branches=subspace/*"
87
88'
89
90test_expect_success 'rev-parse --branches=subspace/' '
91
92 compare rev-parse "subspace/one subspace/two" "--branches=subspace/"
93
94'
95
96test_expect_success 'rev-parse --branches=subspace' '
97
98 compare rev-parse "subspace/one subspace/two" "--branches=subspace"
99
100'
101
d08bae7e
IL
102test_expect_success 'rev-parse --glob=heads/subspace/* --glob=heads/other/*' '
103
104 compare rev-parse "subspace/one subspace/two other/three" "--glob=heads/subspace/* --glob=heads/other/*"
105
106'
107
108test_expect_success 'rev-parse --glob=heads/someref/* master' '
109
110 compare rev-parse "master" "--glob=heads/someref/* master"
111
112'
113
114test_expect_success 'rev-parse --glob=heads/*' '
115
116 compare rev-parse "master other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*"
117
118'
119
b09fe971
IL
120test_expect_success 'rev-parse --tags=foo' '
121
122 compare rev-parse "foo/bar" "--tags=foo"
123
124'
125
126test_expect_success 'rev-parse --remotes=foo' '
127
128 compare rev-parse "foo/baz" "--remotes=foo"
129
130'
131
9dc01bf0
JH
132test_expect_success 'rev-parse --exclude with --branches' '
133 compare rev-parse "--exclude=*/* --branches" "master someref subspace-x"
134'
135
136test_expect_success 'rev-parse --exclude with --all' '
137 compare rev-parse "--exclude=refs/remotes/* --all" "--branches --tags"
138'
139
140test_expect_success 'rev-parse accumulates multiple --exclude' '
141 compare rev-parse "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches
142'
143
d08bae7e
IL
144test_expect_success 'rev-list --glob=refs/heads/subspace/*' '
145
146 compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/*"
147
148'
149
5adba90d
MM
150test_expect_success 'rev-list --glob refs/heads/subspace/*' '
151
152 compare rev-list "subspace/one subspace/two" "--glob refs/heads/subspace/*"
153
154'
155
0fc63ec4
JN
156test_expect_success 'rev-list not confused by option-like --glob arg' '
157
158 compare rev-list "master" "--glob -0 master"
159
160'
161
d08bae7e
IL
162test_expect_success 'rev-list --glob=heads/subspace/*' '
163
164 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/*"
165
166'
167
168test_expect_success 'rev-list --glob=refs/heads/subspace/' '
169
170 compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/"
171
172'
173
174test_expect_success 'rev-list --glob=heads/subspace/' '
175
176 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/"
177
178'
179
180test_expect_success 'rev-list --glob=heads/subspace' '
181
182 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace"
183
184'
185
b09fe971
IL
186test_expect_success 'rev-list --branches=subspace/*' '
187
188 compare rev-list "subspace/one subspace/two" "--branches=subspace/*"
189
190'
191
192test_expect_success 'rev-list --branches=subspace/' '
193
194 compare rev-list "subspace/one subspace/two" "--branches=subspace/"
195
196'
197
198test_expect_success 'rev-list --branches=subspace' '
199
200 compare rev-list "subspace/one subspace/two" "--branches=subspace"
201
202'
9332441d
MG
203
204test_expect_success 'rev-list --branches' '
205
206 compare rev-list "master subspace-x someref other/three subspace/one subspace/two" "--branches"
207
208'
209
d08bae7e
IL
210test_expect_success 'rev-list --glob=heads/someref/* master' '
211
212 compare rev-list "master" "--glob=heads/someref/* master"
213
214'
215
216test_expect_success 'rev-list --glob=heads/subspace/* --glob=heads/other/*' '
217
218 compare rev-list "subspace/one subspace/two other/three" "--glob=heads/subspace/* --glob=heads/other/*"
219
220'
221
222test_expect_success 'rev-list --glob=heads/*' '
223
224 compare rev-list "master other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*"
225
226'
227
b09fe971
IL
228test_expect_success 'rev-list --tags=foo' '
229
230 compare rev-list "foo/bar" "--tags=foo"
231
232'
233
9332441d
MG
234test_expect_success 'rev-list --tags' '
235
236 compare rev-list "foo/bar" "--tags"
237
238'
239
b09fe971
IL
240test_expect_success 'rev-list --remotes=foo' '
241
242 compare rev-list "foo/baz" "--remotes=foo"
243
244'
245
751a2ac6
JH
246test_expect_success 'rev-list --exclude with --branches' '
247 compare rev-list "--exclude=*/* --branches" "master someref subspace-x"
248'
249
250test_expect_success 'rev-list --exclude with --all' '
251 compare rev-list "--exclude=refs/remotes/* --all" "--branches --tags"
252'
253
254test_expect_success 'rev-list accumulates multiple --exclude' '
255 compare rev-list "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches
256'
257
0c5dc743 258test_expect_failure 'rev-list should succeed with empty output on empty stdin' '
b89b4a66 259 git rev-list --stdin </dev/null >actual &&
d3c6751b 260 test_must_be_empty actual
751a2ac6
JH
261'
262
0159ba32 263test_expect_success 'rev-list should succeed with empty output with all refs excluded' '
751a2ac6 264 git rev-list --exclude=* --all >actual &&
d3c6751b 265 test_must_be_empty actual
751a2ac6
JH
266'
267
0159ba32 268test_expect_success 'rev-list should succeed with empty output with empty --all' '
751a2ac6
JH
269 (
270 test_create_repo empty &&
271 cd empty &&
751a2ac6 272 git rev-list --all >actual &&
d3c6751b 273 test_must_be_empty actual
751a2ac6
JH
274 )
275'
276
0159ba32 277test_expect_success 'rev-list should succeed with empty output with empty glob' '
0c5dc743 278 git rev-list --glob=does-not-match-anything >actual &&
d3c6751b 279 test_must_be_empty actual
0c5dc743
JK
280'
281
0fc63ec4
JN
282test_expect_success 'shortlog accepts --glob/--tags/--remotes' '
283
284 compare shortlog "subspace/one subspace/two" --branches=subspace &&
285 compare shortlog \
286 "master subspace-x someref other/three subspace/one subspace/two" \
287 --branches &&
288 compare shortlog master "--glob=heads/someref/* master" &&
289 compare shortlog "subspace/one subspace/two other/three" \
290 "--glob=heads/subspace/* --glob=heads/other/*" &&
291 compare shortlog \
292 "master other/three someref subspace-x subspace/one subspace/two" \
293 "--glob=heads/*" &&
294 compare shortlog foo/bar --tags=foo &&
295 compare shortlog foo/bar --tags &&
296 compare shortlog foo/baz --remotes=foo
297
298'
299
300test_expect_failure 'shortlog accepts --glob as detached option' '
301
302 compare shortlog \
303 "master other/three someref subspace-x subspace/one subspace/two" \
304 "--glob heads/*"
305
306'
307
308test_expect_failure 'shortlog --glob is not confused by option-like argument' '
309
310 compare shortlog master "--glob -e master"
311
312'
313
d08bae7e 314test_done