]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6018-rev-list-glob.sh
tests: mark tests relying on the current default for `init.defaultBranch`
[thirdparty/git.git] / t / t6018-rev-list-glob.sh
CommitLineData
d08bae7e
IL
1#!/bin/sh
2
3test_description='rev-list/rev-parse --glob'
4
334afbc7
JS
5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
d08bae7e
IL
8. ./test-lib.sh
9
10commit () {
11 test_tick &&
12 echo $1 > foo &&
13 git add foo &&
14 git commit -m "$1"
15}
16
17compare () {
18 # Split arguments on whitespace.
19 git $1 $2 >expected &&
20 git $1 $3 >actual &&
21 test_cmp expected actual
22}
23
24test_expect_success 'setup' '
25
26 commit master &&
27 git checkout -b subspace/one master &&
28 commit one &&
29 git checkout -b subspace/two master &&
30 commit two &&
31 git checkout -b subspace-x master &&
32 commit subspace-x &&
33 git checkout -b other/three master &&
34 commit three &&
35 git checkout -b someref master &&
36 commit some &&
37 git checkout master &&
b6211b89 38 commit topic_2 &&
b09fe971 39 git tag foo/bar master &&
b6211b89 40 commit topic_3 &&
52663475 41 git update-ref refs/remotes/foo/baz master &&
b6211b89 42 commit topic_4 &&
9d55dca2
RA
43 git update-ref refs/remotes/upstream/one subspace/one &&
44 git update-ref refs/remotes/upstream/two subspace/two &&
45 git update-ref refs/remotes/upstream/x subspace-x &&
46 git tag qux/one subspace/one &&
47 git tag qux/two subspace/two &&
48 git tag qux/x subspace-x
d08bae7e
IL
49'
50
51test_expect_success 'rev-parse --glob=refs/heads/subspace/*' '
52
53 compare rev-parse "subspace/one subspace/two" "--glob=refs/heads/subspace/*"
54
55'
56
57test_expect_success 'rev-parse --glob=heads/subspace/*' '
58
59 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace/*"
60
61'
62
63test_expect_success 'rev-parse --glob=refs/heads/subspace/' '
64
65 compare rev-parse "subspace/one subspace/two" "--glob=refs/heads/subspace/"
66
67'
68
69test_expect_success 'rev-parse --glob=heads/subspace/' '
70
71 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace/"
72
73'
74
75test_expect_success 'rev-parse --glob=heads/subspace' '
76
77 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace"
78
79'
80
0fc63ec4
JN
81test_expect_failure 'rev-parse accepts --glob as detached option' '
82
83 compare rev-parse "subspace/one subspace/two" "--glob heads/subspace"
84
85'
86
87test_expect_failure 'rev-parse is not confused by option-like glob' '
88
89 compare rev-parse "master" "--glob --symbolic master"
90
91'
92
b09fe971
IL
93test_expect_success 'rev-parse --branches=subspace/*' '
94
95 compare rev-parse "subspace/one subspace/two" "--branches=subspace/*"
96
97'
98
99test_expect_success 'rev-parse --branches=subspace/' '
100
101 compare rev-parse "subspace/one subspace/two" "--branches=subspace/"
102
103'
104
105test_expect_success 'rev-parse --branches=subspace' '
106
107 compare rev-parse "subspace/one subspace/two" "--branches=subspace"
108
109'
110
d08bae7e
IL
111test_expect_success 'rev-parse --glob=heads/subspace/* --glob=heads/other/*' '
112
113 compare rev-parse "subspace/one subspace/two other/three" "--glob=heads/subspace/* --glob=heads/other/*"
114
115'
116
117test_expect_success 'rev-parse --glob=heads/someref/* master' '
118
119 compare rev-parse "master" "--glob=heads/someref/* master"
120
121'
122
123test_expect_success 'rev-parse --glob=heads/*' '
124
125 compare rev-parse "master other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*"
126
127'
128
b09fe971
IL
129test_expect_success 'rev-parse --tags=foo' '
130
131 compare rev-parse "foo/bar" "--tags=foo"
132
133'
134
135test_expect_success 'rev-parse --remotes=foo' '
136
137 compare rev-parse "foo/baz" "--remotes=foo"
138
139'
140
9dc01bf0
JH
141test_expect_success 'rev-parse --exclude with --branches' '
142 compare rev-parse "--exclude=*/* --branches" "master someref subspace-x"
143'
144
145test_expect_success 'rev-parse --exclude with --all' '
146 compare rev-parse "--exclude=refs/remotes/* --all" "--branches --tags"
147'
148
149test_expect_success 'rev-parse accumulates multiple --exclude' '
150 compare rev-parse "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches
151'
152
52210480
AG
153test_expect_success 'rev-parse --branches clears --exclude' '
154 compare rev-parse "--exclude=* --branches --branches" "--branches"
155'
156
157test_expect_success 'rev-parse --tags clears --exclude' '
158 compare rev-parse "--exclude=* --tags --tags" "--tags"
159'
160
161test_expect_success 'rev-parse --all clears --exclude' '
162 compare rev-parse "--exclude=* --all --all" "--all"
163'
164
9ab9b5df 165test_expect_success 'rev-parse --exclude=glob with --branches=glob' '
9d55dca2
RA
166 compare rev-parse "--exclude=subspace-* --branches=sub*" "subspace/one subspace/two"
167'
168
9ab9b5df 169test_expect_success 'rev-parse --exclude=glob with --tags=glob' '
9d55dca2
RA
170 compare rev-parse "--exclude=qux/? --tags=qux/*" "qux/one qux/two"
171'
172
9ab9b5df 173test_expect_success 'rev-parse --exclude=glob with --remotes=glob' '
9d55dca2
RA
174 compare rev-parse "--exclude=upstream/? --remotes=upstream/*" "upstream/one upstream/two"
175'
176
9ab9b5df 177test_expect_success 'rev-parse --exclude=ref with --branches=glob' '
9d55dca2
RA
178 compare rev-parse "--exclude=subspace-x --branches=sub*" "subspace/one subspace/two"
179'
180
9ab9b5df 181test_expect_success 'rev-parse --exclude=ref with --tags=glob' '
9d55dca2
RA
182 compare rev-parse "--exclude=qux/x --tags=qux/*" "qux/one qux/two"
183'
184
9ab9b5df 185test_expect_success 'rev-parse --exclude=ref with --remotes=glob' '
9d55dca2
RA
186 compare rev-parse "--exclude=upstream/x --remotes=upstream/*" "upstream/one upstream/two"
187'
188
9ab9b5df 189test_expect_success 'rev-list --exclude=glob with --branches=glob' '
9d55dca2
RA
190 compare rev-list "--exclude=subspace-* --branches=sub*" "subspace/one subspace/two"
191'
192
9ab9b5df 193test_expect_success 'rev-list --exclude=glob with --tags=glob' '
9d55dca2
RA
194 compare rev-list "--exclude=qux/? --tags=qux/*" "qux/one qux/two"
195'
196
9ab9b5df 197test_expect_success 'rev-list --exclude=glob with --remotes=glob' '
9d55dca2
RA
198 compare rev-list "--exclude=upstream/? --remotes=upstream/*" "upstream/one upstream/two"
199'
200
9ab9b5df 201test_expect_success 'rev-list --exclude=ref with --branches=glob' '
9d55dca2
RA
202 compare rev-list "--exclude=subspace-x --branches=sub*" "subspace/one subspace/two"
203'
204
9ab9b5df 205test_expect_success 'rev-list --exclude=ref with --tags=glob' '
9d55dca2
RA
206 compare rev-list "--exclude=qux/x --tags=qux/*" "qux/one qux/two"
207'
208
9ab9b5df 209test_expect_success 'rev-list --exclude=ref with --remotes=glob' '
9d55dca2
RA
210 compare rev-list "--exclude=upstream/x --remotes=upstream/*" "upstream/one upstream/two"
211'
212
d08bae7e
IL
213test_expect_success 'rev-list --glob=refs/heads/subspace/*' '
214
215 compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/*"
216
217'
218
5adba90d
MM
219test_expect_success 'rev-list --glob refs/heads/subspace/*' '
220
221 compare rev-list "subspace/one subspace/two" "--glob refs/heads/subspace/*"
222
223'
224
0fc63ec4
JN
225test_expect_success 'rev-list not confused by option-like --glob arg' '
226
227 compare rev-list "master" "--glob -0 master"
228
229'
230
d08bae7e
IL
231test_expect_success 'rev-list --glob=heads/subspace/*' '
232
233 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/*"
234
235'
236
237test_expect_success 'rev-list --glob=refs/heads/subspace/' '
238
239 compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/"
240
241'
242
243test_expect_success 'rev-list --glob=heads/subspace/' '
244
245 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/"
246
247'
248
249test_expect_success 'rev-list --glob=heads/subspace' '
250
251 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace"
252
253'
254
b09fe971
IL
255test_expect_success 'rev-list --branches=subspace/*' '
256
257 compare rev-list "subspace/one subspace/two" "--branches=subspace/*"
258
259'
260
261test_expect_success 'rev-list --branches=subspace/' '
262
263 compare rev-list "subspace/one subspace/two" "--branches=subspace/"
264
265'
266
267test_expect_success 'rev-list --branches=subspace' '
268
269 compare rev-list "subspace/one subspace/two" "--branches=subspace"
270
271'
9332441d
MG
272
273test_expect_success 'rev-list --branches' '
274
275 compare rev-list "master subspace-x someref other/three subspace/one subspace/two" "--branches"
276
277'
278
d08bae7e
IL
279test_expect_success 'rev-list --glob=heads/someref/* master' '
280
281 compare rev-list "master" "--glob=heads/someref/* master"
282
283'
284
285test_expect_success 'rev-list --glob=heads/subspace/* --glob=heads/other/*' '
286
287 compare rev-list "subspace/one subspace/two other/three" "--glob=heads/subspace/* --glob=heads/other/*"
288
289'
290
291test_expect_success 'rev-list --glob=heads/*' '
292
293 compare rev-list "master other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*"
294
295'
296
b09fe971
IL
297test_expect_success 'rev-list --tags=foo' '
298
299 compare rev-list "foo/bar" "--tags=foo"
300
301'
302
9332441d
MG
303test_expect_success 'rev-list --tags' '
304
9d55dca2 305 compare rev-list "foo/bar qux/x qux/two qux/one" "--tags"
9332441d
MG
306
307'
308
b09fe971
IL
309test_expect_success 'rev-list --remotes=foo' '
310
311 compare rev-list "foo/baz" "--remotes=foo"
312
313'
314
751a2ac6
JH
315test_expect_success 'rev-list --exclude with --branches' '
316 compare rev-list "--exclude=*/* --branches" "master someref subspace-x"
317'
318
319test_expect_success 'rev-list --exclude with --all' '
320 compare rev-list "--exclude=refs/remotes/* --all" "--branches --tags"
321'
322
323test_expect_success 'rev-list accumulates multiple --exclude' '
324 compare rev-list "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches
325'
326
a12cbe23 327test_expect_success 'rev-list should succeed with empty output on empty stdin' '
b89b4a66 328 git rev-list --stdin </dev/null >actual &&
d3c6751b 329 test_must_be_empty actual
751a2ac6
JH
330'
331
0159ba32 332test_expect_success 'rev-list should succeed with empty output with all refs excluded' '
751a2ac6 333 git rev-list --exclude=* --all >actual &&
d3c6751b 334 test_must_be_empty actual
751a2ac6
JH
335'
336
0159ba32 337test_expect_success 'rev-list should succeed with empty output with empty --all' '
751a2ac6
JH
338 (
339 test_create_repo empty &&
340 cd empty &&
751a2ac6 341 git rev-list --all >actual &&
d3c6751b 342 test_must_be_empty actual
751a2ac6
JH
343 )
344'
345
0159ba32 346test_expect_success 'rev-list should succeed with empty output with empty glob' '
0c5dc743 347 git rev-list --glob=does-not-match-anything >actual &&
d3c6751b 348 test_must_be_empty actual
04a0e985
JK
349'
350
351test_expect_success 'rev-list should succeed with empty output when ignoring missing' '
352 git rev-list --ignore-missing $ZERO_OID >actual &&
353 test_must_be_empty actual
0c5dc743
JK
354'
355
0fc63ec4
JN
356test_expect_success 'shortlog accepts --glob/--tags/--remotes' '
357
358 compare shortlog "subspace/one subspace/two" --branches=subspace &&
359 compare shortlog \
360 "master subspace-x someref other/three subspace/one subspace/two" \
361 --branches &&
362 compare shortlog master "--glob=heads/someref/* master" &&
363 compare shortlog "subspace/one subspace/two other/three" \
364 "--glob=heads/subspace/* --glob=heads/other/*" &&
365 compare shortlog \
366 "master other/three someref subspace-x subspace/one subspace/two" \
367 "--glob=heads/*" &&
368 compare shortlog foo/bar --tags=foo &&
9d55dca2 369 compare shortlog "foo/bar qux/one qux/two qux/x" --tags &&
0fc63ec4
JN
370 compare shortlog foo/baz --remotes=foo
371
372'
373
374test_expect_failure 'shortlog accepts --glob as detached option' '
375
376 compare shortlog \
377 "master other/three someref subspace-x subspace/one subspace/two" \
378 "--glob heads/*"
379
380'
381
382test_expect_failure 'shortlog --glob is not confused by option-like argument' '
383
384 compare shortlog master "--glob -e master"
385
386'
387
d08bae7e 388test_done