rebase: really just passthru the `git am` options
[git/debian.git] / t / t6018-rev-list-glob.sh
blob270e579c2d3a30b2a08517bc63fe6edf5221af59
1 #!/bin/sh
3 test_description='rev-list/rev-parse --glob'
5 . ./test-lib.sh
7 commit () {
8 test_tick &&
9 echo $1 > foo &&
10 git add foo &&
11 git commit -m "$1"
14 compare () {
15 # Split arguments on whitespace.
16 git $1 $2 >expected &&
17 git $1 $3 >actual &&
18 test_cmp expected actual
21 test_expect_success 'setup' '
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 &&
35 commit master2 &&
36 git tag foo/bar master &&
37 commit master3 &&
38 git update-ref refs/remotes/foo/baz master &&
39 commit master4
42 test_expect_success 'rev-parse --glob=refs/heads/subspace/*' '
44 compare rev-parse "subspace/one subspace/two" "--glob=refs/heads/subspace/*"
48 test_expect_success 'rev-parse --glob=heads/subspace/*' '
50 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace/*"
54 test_expect_success 'rev-parse --glob=refs/heads/subspace/' '
56 compare rev-parse "subspace/one subspace/two" "--glob=refs/heads/subspace/"
60 test_expect_success 'rev-parse --glob=heads/subspace/' '
62 compare rev-parse "subspace/one subspace/two" "--glob=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_failure 'rev-parse accepts --glob as detached option' '
74 compare rev-parse "subspace/one subspace/two" "--glob heads/subspace"
78 test_expect_failure 'rev-parse is not confused by option-like glob' '
80 compare rev-parse "master" "--glob --symbolic master"
84 test_expect_success 'rev-parse --branches=subspace/*' '
86 compare rev-parse "subspace/one subspace/two" "--branches=subspace/*"
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 --glob=heads/subspace/* --glob=heads/other/*' '
104 compare rev-parse "subspace/one subspace/two other/three" "--glob=heads/subspace/* --glob=heads/other/*"
108 test_expect_success 'rev-parse --glob=heads/someref/* master' '
110 compare rev-parse "master" "--glob=heads/someref/* master"
114 test_expect_success 'rev-parse --glob=heads/*' '
116 compare rev-parse "master other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*"
120 test_expect_success 'rev-parse --tags=foo' '
122 compare rev-parse "foo/bar" "--tags=foo"
126 test_expect_success 'rev-parse --remotes=foo' '
128 compare rev-parse "foo/baz" "--remotes=foo"
132 test_expect_success 'rev-parse --exclude with --branches' '
133 compare rev-parse "--exclude=*/* --branches" "master someref subspace-x"
136 test_expect_success 'rev-parse --exclude with --all' '
137 compare rev-parse "--exclude=refs/remotes/* --all" "--branches --tags"
140 test_expect_success 'rev-parse accumulates multiple --exclude' '
141 compare rev-parse "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches
144 test_expect_success 'rev-parse --branches clears --exclude' '
145 compare rev-parse "--exclude=* --branches --branches" "--branches"
148 test_expect_success 'rev-parse --tags clears --exclude' '
149 compare rev-parse "--exclude=* --tags --tags" "--tags"
152 test_expect_success 'rev-parse --all clears --exclude' '
153 compare rev-parse "--exclude=* --all --all" "--all"
156 test_expect_success 'rev-list --glob=refs/heads/subspace/*' '
158 compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/*"
162 test_expect_success 'rev-list --glob refs/heads/subspace/*' '
164 compare rev-list "subspace/one subspace/two" "--glob refs/heads/subspace/*"
168 test_expect_success 'rev-list not confused by option-like --glob arg' '
170 compare rev-list "master" "--glob -0 master"
174 test_expect_success 'rev-list --glob=heads/subspace/*' '
176 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/*"
180 test_expect_success 'rev-list --glob=refs/heads/subspace/' '
182 compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/"
186 test_expect_success 'rev-list --glob=heads/subspace/' '
188 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/"
192 test_expect_success 'rev-list --glob=heads/subspace' '
194 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace"
198 test_expect_success 'rev-list --branches=subspace/*' '
200 compare rev-list "subspace/one subspace/two" "--branches=subspace/*"
204 test_expect_success 'rev-list --branches=subspace/' '
206 compare rev-list "subspace/one subspace/two" "--branches=subspace/"
210 test_expect_success 'rev-list --branches=subspace' '
212 compare rev-list "subspace/one subspace/two" "--branches=subspace"
216 test_expect_success 'rev-list --branches' '
218 compare rev-list "master subspace-x someref other/three subspace/one subspace/two" "--branches"
222 test_expect_success 'rev-list --glob=heads/someref/* master' '
224 compare rev-list "master" "--glob=heads/someref/* master"
228 test_expect_success 'rev-list --glob=heads/subspace/* --glob=heads/other/*' '
230 compare rev-list "subspace/one subspace/two other/three" "--glob=heads/subspace/* --glob=heads/other/*"
234 test_expect_success 'rev-list --glob=heads/*' '
236 compare rev-list "master other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*"
240 test_expect_success 'rev-list --tags=foo' '
242 compare rev-list "foo/bar" "--tags=foo"
246 test_expect_success 'rev-list --tags' '
248 compare rev-list "foo/bar" "--tags"
252 test_expect_success 'rev-list --remotes=foo' '
254 compare rev-list "foo/baz" "--remotes=foo"
258 test_expect_success 'rev-list --exclude with --branches' '
259 compare rev-list "--exclude=*/* --branches" "master someref subspace-x"
262 test_expect_success 'rev-list --exclude with --all' '
263 compare rev-list "--exclude=refs/remotes/* --all" "--branches --tags"
266 test_expect_success 'rev-list accumulates multiple --exclude' '
267 compare rev-list "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches
270 test_expect_success 'rev-list should succeed with empty output on empty stdin' '
271 git rev-list --stdin </dev/null >actual &&
272 test_must_be_empty actual
275 test_expect_success 'rev-list should succeed with empty output with all refs excluded' '
276 git rev-list --exclude=* --all >actual &&
277 test_must_be_empty actual
280 test_expect_success 'rev-list should succeed with empty output with empty --all' '
282 test_create_repo empty &&
283 cd empty &&
284 git rev-list --all >actual &&
285 test_must_be_empty actual
289 test_expect_success 'rev-list should succeed with empty output with empty glob' '
290 git rev-list --glob=does-not-match-anything >actual &&
291 test_must_be_empty actual
294 test_expect_success 'shortlog accepts --glob/--tags/--remotes' '
296 compare shortlog "subspace/one subspace/two" --branches=subspace &&
297 compare shortlog \
298 "master subspace-x someref other/three subspace/one subspace/two" \
299 --branches &&
300 compare shortlog master "--glob=heads/someref/* master" &&
301 compare shortlog "subspace/one subspace/two other/three" \
302 "--glob=heads/subspace/* --glob=heads/other/*" &&
303 compare shortlog \
304 "master other/three someref subspace-x subspace/one subspace/two" \
305 "--glob=heads/*" &&
306 compare shortlog foo/bar --tags=foo &&
307 compare shortlog foo/bar --tags &&
308 compare shortlog foo/baz --remotes=foo
312 test_expect_failure 'shortlog accepts --glob as detached option' '
314 compare shortlog \
315 "master other/three someref subspace-x subspace/one subspace/two" \
316 "--glob heads/*"
320 test_expect_failure 'shortlog --glob is not confused by option-like argument' '
322 compare shortlog master "--glob -e master"
326 test_done