Merge branch 'ml/maint-grep-doc' into maint
[tgit.git] / t / t6018-rev-list-glob.sh
blob8d3fa7d014c1e5a856f6c4c35cfb46eb8c44e684
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 git update-ref refs/remotes/foo/baz master
40 test_expect_success 'rev-parse --glob=refs/heads/subspace/*' '
42 compare rev-parse "subspace/one subspace/two" "--glob=refs/heads/subspace/*"
46 test_expect_success 'rev-parse --glob=heads/subspace/*' '
48 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace/*"
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=heads/subspace' '
66 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace"
70 test_expect_success 'rev-parse --branches=subspace/*' '
72 compare rev-parse "subspace/one subspace/two" "--branches=subspace/*"
76 test_expect_success 'rev-parse --branches=subspace/' '
78 compare rev-parse "subspace/one subspace/two" "--branches=subspace/"
82 test_expect_success 'rev-parse --branches=subspace' '
84 compare rev-parse "subspace/one subspace/two" "--branches=subspace"
88 test_expect_success 'rev-parse --glob=heads/subspace/* --glob=heads/other/*' '
90 compare rev-parse "subspace/one subspace/two other/three" "--glob=heads/subspace/* --glob=heads/other/*"
94 test_expect_success 'rev-parse --glob=heads/someref/* master' '
96 compare rev-parse "master" "--glob=heads/someref/* master"
100 test_expect_success 'rev-parse --glob=heads/*' '
102 compare rev-parse "master other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*"
106 test_expect_success 'rev-parse --tags=foo' '
108 compare rev-parse "foo/bar" "--tags=foo"
112 test_expect_success 'rev-parse --remotes=foo' '
114 compare rev-parse "foo/baz" "--remotes=foo"
118 test_expect_success 'rev-list --glob=refs/heads/subspace/*' '
120 compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/*"
124 test_expect_success 'rev-list --glob=heads/subspace/*' '
126 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/*"
130 test_expect_success 'rev-list --glob=refs/heads/subspace/' '
132 compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/"
136 test_expect_success 'rev-list --glob=heads/subspace/' '
138 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/"
142 test_expect_success 'rev-list --glob=heads/subspace' '
144 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace"
148 test_expect_success 'rev-list --branches=subspace/*' '
150 compare rev-list "subspace/one subspace/two" "--branches=subspace/*"
154 test_expect_success 'rev-list --branches=subspace/' '
156 compare rev-list "subspace/one subspace/two" "--branches=subspace/"
160 test_expect_success 'rev-list --branches=subspace' '
162 compare rev-list "subspace/one subspace/two" "--branches=subspace"
165 test_expect_success 'rev-list --glob=heads/someref/* master' '
167 compare rev-list "master" "--glob=heads/someref/* master"
171 test_expect_success 'rev-list --glob=heads/subspace/* --glob=heads/other/*' '
173 compare rev-list "subspace/one subspace/two other/three" "--glob=heads/subspace/* --glob=heads/other/*"
177 test_expect_success 'rev-list --glob=heads/*' '
179 compare rev-list "master other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*"
183 test_expect_success 'rev-list --tags=foo' '
185 compare rev-list "foo/bar" "--tags=foo"
189 test_expect_success 'rev-list --remotes=foo' '
191 compare rev-list "foo/baz" "--remotes=foo"
195 test_done