]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t6018-rev-list-glob.sh
3 test_description
='rev-list/rev-parse --glob'
15 # Split arguments on whitespace.
16 git
$1 $2 >expected
&&
18 test_cmp expected actual
21 test_expect_success
'setup' '
24 git checkout -b subspace/one master &&
26 git checkout -b subspace/two master &&
28 git checkout -b subspace-x master &&
30 git checkout -b other/three master &&
32 git checkout -b someref master &&
34 git checkout master &&
36 git tag foo/bar master &&
38 git update-ref refs/remotes/foo/baz master &&
40 git update-ref refs/remotes/upstream/one subspace/one &&
41 git update-ref refs/remotes/upstream/two subspace/two &&
42 git update-ref refs/remotes/upstream/x subspace-x &&
43 git tag qux/one subspace/one &&
44 git tag qux/two subspace/two &&
45 git tag qux/x subspace-x
48 test_expect_success
'rev-parse --glob=refs/heads/subspace/*' '
50 compare rev-parse "subspace/one subspace/two" "--glob=refs/heads/subspace/*"
54 test_expect_success
'rev-parse --glob=heads/subspace/*' '
56 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace/*"
60 test_expect_success
'rev-parse --glob=refs/heads/subspace/' '
62 compare rev-parse "subspace/one subspace/two" "--glob=refs/heads/subspace/"
66 test_expect_success
'rev-parse --glob=heads/subspace/' '
68 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace/"
72 test_expect_success
'rev-parse --glob=heads/subspace' '
74 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace"
78 test_expect_failure
'rev-parse accepts --glob as detached option' '
80 compare rev-parse "subspace/one subspace/two" "--glob heads/subspace"
84 test_expect_failure
'rev-parse is not confused by option-like glob' '
86 compare rev-parse "master" "--glob --symbolic master"
90 test_expect_success
'rev-parse --branches=subspace/*' '
92 compare rev-parse "subspace/one subspace/two" "--branches=subspace/*"
96 test_expect_success
'rev-parse --branches=subspace/' '
98 compare rev-parse "subspace/one subspace/two" "--branches=subspace/"
102 test_expect_success
'rev-parse --branches=subspace' '
104 compare rev-parse "subspace/one subspace/two" "--branches=subspace"
108 test_expect_success
'rev-parse --glob=heads/subspace/* --glob=heads/other/*' '
110 compare rev-parse "subspace/one subspace/two other/three" "--glob=heads/subspace/* --glob=heads/other/*"
114 test_expect_success
'rev-parse --glob=heads/someref/* master' '
116 compare rev-parse "master" "--glob=heads/someref/* master"
120 test_expect_success
'rev-parse --glob=heads/*' '
122 compare rev-parse "master other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*"
126 test_expect_success
'rev-parse --tags=foo' '
128 compare rev-parse "foo/bar" "--tags=foo"
132 test_expect_success
'rev-parse --remotes=foo' '
134 compare rev-parse "foo/baz" "--remotes=foo"
138 test_expect_success
'rev-parse --exclude with --branches' '
139 compare rev-parse "--exclude=*/* --branches" "master someref subspace-x"
142 test_expect_success
'rev-parse --exclude with --all' '
143 compare rev-parse "--exclude=refs/remotes/* --all" "--branches --tags"
146 test_expect_success
'rev-parse accumulates multiple --exclude' '
147 compare rev-parse "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches
150 test_expect_failure
'rev-parse --exclude=glob with --branches=glob' '
151 compare rev-parse "--exclude=subspace-* --branches=sub*" "subspace/one subspace/two"
154 test_expect_failure
'rev-parse --exclude=glob with --tags=glob' '
155 compare rev-parse "--exclude=qux/? --tags=qux/*" "qux/one qux/two"
158 test_expect_failure
'rev-parse --exclude=glob with --remotes=glob' '
159 compare rev-parse "--exclude=upstream/? --remotes=upstream/*" "upstream/one upstream/two"
162 test_expect_failure
'rev-parse --exclude=ref with --branches=glob' '
163 compare rev-parse "--exclude=subspace-x --branches=sub*" "subspace/one subspace/two"
166 test_expect_failure
'rev-parse --exclude=ref with --tags=glob' '
167 compare rev-parse "--exclude=qux/x --tags=qux/*" "qux/one qux/two"
170 test_expect_failure
'rev-parse --exclude=ref with --remotes=glob' '
171 compare rev-parse "--exclude=upstream/x --remotes=upstream/*" "upstream/one upstream/two"
174 test_expect_failure
'rev-list --exclude=glob with --branches=glob' '
175 compare rev-list "--exclude=subspace-* --branches=sub*" "subspace/one subspace/two"
178 test_expect_failure
'rev-list --exclude=glob with --tags=glob' '
179 compare rev-list "--exclude=qux/? --tags=qux/*" "qux/one qux/two"
182 test_expect_failure
'rev-list --exclude=glob with --remotes=glob' '
183 compare rev-list "--exclude=upstream/? --remotes=upstream/*" "upstream/one upstream/two"
186 test_expect_failure
'rev-list --exclude=ref with --branches=glob' '
187 compare rev-list "--exclude=subspace-x --branches=sub*" "subspace/one subspace/two"
190 test_expect_failure
'rev-list --exclude=ref with --tags=glob' '
191 compare rev-list "--exclude=qux/x --tags=qux/*" "qux/one qux/two"
194 test_expect_failure
'rev-list --exclude=ref with --remotes=glob' '
195 compare rev-list "--exclude=upstream/x --remotes=upstream/*" "upstream/one upstream/two"
198 test_expect_success
'rev-list --glob=refs/heads/subspace/*' '
200 compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/*"
204 test_expect_success
'rev-list --glob refs/heads/subspace/*' '
206 compare rev-list "subspace/one subspace/two" "--glob refs/heads/subspace/*"
210 test_expect_success
'rev-list not confused by option-like --glob arg' '
212 compare rev-list "master" "--glob -0 master"
216 test_expect_success
'rev-list --glob=heads/subspace/*' '
218 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/*"
222 test_expect_success
'rev-list --glob=refs/heads/subspace/' '
224 compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/"
228 test_expect_success
'rev-list --glob=heads/subspace/' '
230 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/"
234 test_expect_success
'rev-list --glob=heads/subspace' '
236 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace"
240 test_expect_success
'rev-list --branches=subspace/*' '
242 compare rev-list "subspace/one subspace/two" "--branches=subspace/*"
246 test_expect_success
'rev-list --branches=subspace/' '
248 compare rev-list "subspace/one subspace/two" "--branches=subspace/"
252 test_expect_success
'rev-list --branches=subspace' '
254 compare rev-list "subspace/one subspace/two" "--branches=subspace"
258 test_expect_success
'rev-list --branches' '
260 compare rev-list "master subspace-x someref other/three subspace/one subspace/two" "--branches"
264 test_expect_success
'rev-list --glob=heads/someref/* master' '
266 compare rev-list "master" "--glob=heads/someref/* master"
270 test_expect_success
'rev-list --glob=heads/subspace/* --glob=heads/other/*' '
272 compare rev-list "subspace/one subspace/two other/three" "--glob=heads/subspace/* --glob=heads/other/*"
276 test_expect_success
'rev-list --glob=heads/*' '
278 compare rev-list "master other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*"
282 test_expect_success
'rev-list --tags=foo' '
284 compare rev-list "foo/bar" "--tags=foo"
288 test_expect_success
'rev-list --tags' '
290 compare rev-list "foo/bar qux/x qux/two qux/one" "--tags"
294 test_expect_success
'rev-list --remotes=foo' '
296 compare rev-list "foo/baz" "--remotes=foo"
300 test_expect_success
'rev-list --exclude with --branches' '
301 compare rev-list "--exclude=*/* --branches" "master someref subspace-x"
304 test_expect_success
'rev-list --exclude with --all' '
305 compare rev-list "--exclude=refs/remotes/* --all" "--branches --tags"
308 test_expect_success
'rev-list accumulates multiple --exclude' '
309 compare rev-list "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches
312 test_expect_failure
'rev-list should succeed with empty output on empty stdin' '
313 git rev-list --stdin </dev/null >actual &&
314 test_must_be_empty actual
317 test_expect_success
'rev-list should succeed with empty output with all refs excluded' '
318 git rev-list --exclude=* --all >actual &&
319 test_must_be_empty actual
322 test_expect_success
'rev-list should succeed with empty output with empty --all' '
324 test_create_repo empty &&
326 git rev-list --all >actual &&
327 test_must_be_empty actual
331 test_expect_success
'rev-list should succeed with empty output with empty glob' '
332 git rev-list --glob=does-not-match-anything >actual &&
333 test_must_be_empty actual
336 test_expect_success
'shortlog accepts --glob/--tags/--remotes' '
338 compare shortlog "subspace/one subspace/two" --branches=subspace &&
340 "master subspace-x someref other/three subspace/one subspace/two" \
342 compare shortlog master "--glob=heads/someref/* master" &&
343 compare shortlog "subspace/one subspace/two other/three" \
344 "--glob=heads/subspace/* --glob=heads/other/*" &&
346 "master other/three someref subspace-x subspace/one subspace/two" \
348 compare shortlog foo/bar --tags=foo &&
349 compare shortlog "foo/bar qux/one qux/two qux/x" --tags &&
350 compare shortlog foo/baz --remotes=foo
354 test_expect_failure
'shortlog accepts --glob as detached option' '
357 "master other/three someref subspace-x subspace/one subspace/two" \
362 test_expect_failure
'shortlog --glob is not confused by option-like argument' '
364 compare shortlog master "--glob -e master"