t7800: improve test descriptions with empty arguments
[alt-git.git] / t / t6018-rev-list-glob.sh
blob3b181f771c25a3d8a074f7d0472bf1f0422f582b
1 #!/bin/sh
3 test_description='rev-list/rev-parse --glob'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 commit () {
12 test_tick &&
13 echo $1 > foo &&
14 git add foo &&
15 git commit -m "$1"
18 compare () {
19 # Split arguments on whitespace.
20 git $1 $2 >expected &&
21 git $1 $3 >actual &&
22 test_cmp expected actual
25 test_expect_success 'setup' '
27 commit main &&
28 git checkout -b subspace/one main &&
29 commit one &&
30 git checkout -b subspace/two main &&
31 commit two &&
32 git checkout -b subspace-x main &&
33 commit subspace-x &&
34 git checkout -b other/three main &&
35 commit three &&
36 git checkout -b someref main &&
37 commit some &&
38 git checkout main &&
39 commit topic_2 &&
40 git tag foo/bar main &&
41 commit topic_3 &&
42 git update-ref refs/remotes/foo/baz main &&
43 commit topic_4 &&
44 git update-ref refs/remotes/upstream/one subspace/one &&
45 git update-ref refs/remotes/upstream/two subspace/two &&
46 git update-ref refs/remotes/upstream/x subspace-x &&
47 git tag qux/one subspace/one &&
48 git tag qux/two subspace/two &&
49 git tag qux/x subspace-x
52 test_expect_success 'rev-parse --glob=refs/heads/subspace/*' '
54 compare rev-parse "subspace/one subspace/two" "--glob=refs/heads/subspace/*"
58 test_expect_success 'rev-parse --glob=heads/subspace/*' '
60 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace/*"
64 test_expect_success 'rev-parse --glob=refs/heads/subspace/' '
66 compare rev-parse "subspace/one subspace/two" "--glob=refs/heads/subspace/"
70 test_expect_success 'rev-parse --glob=heads/subspace/' '
72 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace/"
76 test_expect_success 'rev-parse --glob=heads/subspace' '
78 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace"
82 test_expect_failure 'rev-parse accepts --glob as detached option' '
84 compare rev-parse "subspace/one subspace/two" "--glob heads/subspace"
88 test_expect_failure 'rev-parse is not confused by option-like glob' '
90 compare rev-parse "main" "--glob --symbolic main"
94 test_expect_success 'rev-parse --branches=subspace/*' '
96 compare rev-parse "subspace/one subspace/two" "--branches=subspace/*"
100 test_expect_success 'rev-parse --branches=subspace/' '
102 compare rev-parse "subspace/one subspace/two" "--branches=subspace/"
106 test_expect_success 'rev-parse --branches=subspace' '
108 compare rev-parse "subspace/one subspace/two" "--branches=subspace"
112 test_expect_success 'rev-parse --glob=heads/subspace/* --glob=heads/other/*' '
114 compare rev-parse "subspace/one subspace/two other/three" "--glob=heads/subspace/* --glob=heads/other/*"
118 test_expect_success 'rev-parse --glob=heads/someref/* main' '
120 compare rev-parse "main" "--glob=heads/someref/* main"
124 test_expect_success 'rev-parse --glob=heads/*' '
126 compare rev-parse "main other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*"
130 test_expect_success 'rev-parse --tags=foo' '
132 compare rev-parse "foo/bar" "--tags=foo"
136 test_expect_success 'rev-parse --remotes=foo' '
138 compare rev-parse "foo/baz" "--remotes=foo"
142 test_expect_success 'rev-parse --exclude with --branches' '
143 compare rev-parse "--exclude=*/* --branches" "main someref subspace-x"
146 test_expect_success 'rev-parse --exclude with --all' '
147 compare rev-parse "--exclude=refs/remotes/* --all" "--branches --tags"
150 test_expect_success 'rev-parse accumulates multiple --exclude' '
151 compare rev-parse "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches
154 test_expect_success 'rev-parse --branches clears --exclude' '
155 compare rev-parse "--exclude=* --branches --branches" "--branches"
158 test_expect_success 'rev-parse --tags clears --exclude' '
159 compare rev-parse "--exclude=* --tags --tags" "--tags"
162 test_expect_success 'rev-parse --all clears --exclude' '
163 compare rev-parse "--exclude=* --all --all" "--all"
166 test_expect_success 'rev-parse --exclude=glob with --branches=glob' '
167 compare rev-parse "--exclude=subspace-* --branches=sub*" "subspace/one subspace/two"
170 test_expect_success 'rev-parse --exclude=glob with --tags=glob' '
171 compare rev-parse "--exclude=qux/? --tags=qux/*" "qux/one qux/two"
174 test_expect_success 'rev-parse --exclude=glob with --remotes=glob' '
175 compare rev-parse "--exclude=upstream/? --remotes=upstream/*" "upstream/one upstream/two"
178 test_expect_success 'rev-parse --exclude=ref with --branches=glob' '
179 compare rev-parse "--exclude=subspace-x --branches=sub*" "subspace/one subspace/two"
182 test_expect_success 'rev-parse --exclude=ref with --tags=glob' '
183 compare rev-parse "--exclude=qux/x --tags=qux/*" "qux/one qux/two"
186 test_expect_success 'rev-parse --exclude=ref with --remotes=glob' '
187 compare rev-parse "--exclude=upstream/x --remotes=upstream/*" "upstream/one upstream/two"
190 for section in fetch receive uploadpack
192 test_expect_success "rev-parse --exclude-hidden=$section with --all" '
193 compare "-c transfer.hideRefs=refs/remotes/ rev-parse" "--branches --tags" "--exclude-hidden=$section --all"
196 test_expect_success "rev-parse --exclude-hidden=$section with --all" '
197 compare "-c transfer.hideRefs=refs/heads/subspace/ rev-parse" "--exclude=refs/heads/subspace/* --all" "--exclude-hidden=$section --all"
200 test_expect_success "rev-parse --exclude-hidden=$section with --glob" '
201 compare "-c transfer.hideRefs=refs/heads/subspace/ rev-parse" "--exclude=refs/heads/subspace/* --glob=refs/heads/*" "--exclude-hidden=$section --glob=refs/heads/*"
204 test_expect_success "rev-parse --exclude-hidden=$section can be passed once per pseudo-ref" '
205 compare "-c transfer.hideRefs=refs/remotes/ rev-parse" "--branches --tags --branches --tags" "--exclude-hidden=$section --all --exclude-hidden=$section --all"
208 test_expect_success "rev-parse --exclude-hidden=$section can only be passed once per pseudo-ref" '
209 echo "fatal: --exclude-hidden= passed more than once" >expected &&
210 test_must_fail git rev-parse --exclude-hidden=$section --exclude-hidden=$section 2>err &&
211 test_cmp expected err
214 for pseudoopt in branches tags remotes
216 test_expect_success "rev-parse --exclude-hidden=$section fails with --$pseudoopt" '
217 test_must_fail git rev-parse --exclude-hidden=$section --$pseudoopt 2>err &&
218 test_grep "error: options .--exclude-hidden. and .--$pseudoopt. cannot be used together" err
221 test_expect_success "rev-parse --exclude-hidden=$section fails with --$pseudoopt=pattern" '
222 test_must_fail git rev-parse --exclude-hidden=$section --$pseudoopt=pattern 2>err &&
223 test_grep "error: options .--exclude-hidden. and .--$pseudoopt. cannot be used together" err
225 done
226 done
228 test_expect_success 'rev-list --exclude=glob with --branches=glob' '
229 compare rev-list "--exclude=subspace-* --branches=sub*" "subspace/one subspace/two"
232 test_expect_success 'rev-list --exclude=glob with --tags=glob' '
233 compare rev-list "--exclude=qux/? --tags=qux/*" "qux/one qux/two"
236 test_expect_success 'rev-list --exclude=glob with --remotes=glob' '
237 compare rev-list "--exclude=upstream/? --remotes=upstream/*" "upstream/one upstream/two"
240 test_expect_success 'rev-list --exclude=ref with --branches=glob' '
241 compare rev-list "--exclude=subspace-x --branches=sub*" "subspace/one subspace/two"
244 test_expect_success 'rev-list --exclude=ref with --tags=glob' '
245 compare rev-list "--exclude=qux/x --tags=qux/*" "qux/one qux/two"
248 test_expect_success 'rev-list --exclude=ref with --remotes=glob' '
249 compare rev-list "--exclude=upstream/x --remotes=upstream/*" "upstream/one upstream/two"
252 test_expect_success 'rev-list --glob=refs/heads/subspace/*' '
254 compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/*"
258 test_expect_success 'rev-list --glob refs/heads/subspace/*' '
260 compare rev-list "subspace/one subspace/two" "--glob refs/heads/subspace/*"
264 test_expect_success 'rev-list not confused by option-like --glob arg' '
266 compare rev-list "main" "--glob -0 main"
270 test_expect_success 'rev-list --glob=heads/subspace/*' '
272 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/*"
276 test_expect_success 'rev-list --glob=refs/heads/subspace/' '
278 compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/"
282 test_expect_success 'rev-list --glob=heads/subspace/' '
284 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/"
288 test_expect_success 'rev-list --glob=heads/subspace' '
290 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace"
294 test_expect_success 'rev-list --branches=subspace/*' '
296 compare rev-list "subspace/one subspace/two" "--branches=subspace/*"
300 test_expect_success 'rev-list --branches=subspace/' '
302 compare rev-list "subspace/one subspace/two" "--branches=subspace/"
306 test_expect_success 'rev-list --branches=subspace' '
308 compare rev-list "subspace/one subspace/two" "--branches=subspace"
312 test_expect_success 'rev-list --branches' '
314 compare rev-list "main subspace-x someref other/three subspace/one subspace/two" "--branches"
318 test_expect_success 'rev-list --glob=heads/someref/* main' '
320 compare rev-list "main" "--glob=heads/someref/* main"
324 test_expect_success 'rev-list --glob=heads/subspace/* --glob=heads/other/*' '
326 compare rev-list "subspace/one subspace/two other/three" "--glob=heads/subspace/* --glob=heads/other/*"
330 test_expect_success 'rev-list --glob=heads/*' '
332 compare rev-list "main other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*"
336 test_expect_success 'rev-list --tags=foo' '
338 compare rev-list "foo/bar" "--tags=foo"
342 test_expect_success 'rev-list --tags' '
344 compare rev-list "foo/bar qux/x qux/two qux/one" "--tags"
348 test_expect_success 'rev-list --remotes=foo' '
350 compare rev-list "foo/baz" "--remotes=foo"
354 test_expect_success 'rev-list --exclude with --branches' '
355 compare rev-list "--exclude=*/* --branches" "main someref subspace-x"
358 test_expect_success 'rev-list --exclude with --all' '
359 compare rev-list "--exclude=refs/remotes/* --all" "--branches --tags"
362 test_expect_success 'rev-list accumulates multiple --exclude' '
363 compare rev-list "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches
366 test_expect_success 'rev-list should succeed with empty output on empty stdin' '
367 git rev-list --stdin </dev/null >actual &&
368 test_must_be_empty actual
371 test_expect_success 'rev-list should succeed with empty output with all refs excluded' '
372 git rev-list --exclude=* --all >actual &&
373 test_must_be_empty actual
376 test_expect_success 'rev-list should succeed with empty output with empty --all' '
378 test_create_repo empty &&
379 cd empty &&
380 git rev-list --all >actual &&
381 test_must_be_empty actual
385 test_expect_success 'rev-list should succeed with empty output with empty glob' '
386 git rev-list --glob=does-not-match-anything >actual &&
387 test_must_be_empty actual
390 test_expect_success 'rev-list should succeed with empty output when ignoring missing' '
391 git rev-list --ignore-missing $ZERO_OID >actual &&
392 test_must_be_empty actual
395 test_expect_success 'shortlog accepts --glob/--tags/--remotes' '
397 compare shortlog "subspace/one subspace/two" --branches=subspace &&
398 compare shortlog \
399 "main subspace-x someref other/three subspace/one subspace/two" \
400 --branches &&
401 compare shortlog main "--glob=heads/someref/* main" &&
402 compare shortlog "subspace/one subspace/two other/three" \
403 "--glob=heads/subspace/* --glob=heads/other/*" &&
404 compare shortlog \
405 "main other/three someref subspace-x subspace/one subspace/two" \
406 "--glob=heads/*" &&
407 compare shortlog foo/bar --tags=foo &&
408 compare shortlog "foo/bar qux/one qux/two qux/x" --tags &&
409 compare shortlog foo/baz --remotes=foo
413 test_expect_failure 'shortlog accepts --glob as detached option' '
415 compare shortlog \
416 "main other/three someref subspace-x subspace/one subspace/two" \
417 "--glob heads/*"
421 test_expect_failure 'shortlog --glob is not confused by option-like argument' '
423 compare shortlog main "--glob -e main"
427 test_done