1#!/bin/sh
2
3test_description='rev-list/rev-parse --glob'
4
5. ./test-lib.sh
6
7commit () {
8 test_tick &&
9 echo $1 > foo &&
10 git add foo &&
11 git commit -m "$1"
12}
13
14compare () {
15 # Split arguments on whitespace.
16 git $1 $2 >expected &&
17 git $1 $3 >actual &&
18 test_cmp expected actual
19}
20
21test_expect_success 'setup' '
22
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
38'
39
40test_expect_success 'rev-parse --glob=refs/heads/subspace/*' '
41
42 compare rev-parse "subspace/one subspace/two" "--glob=refs/heads/subspace/*"
43
44'
45
46test_expect_success 'rev-parse --glob=heads/subspace/*' '
47
48 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace/*"
49
50'
51
52test_expect_success 'rev-parse --glob=refs/heads/subspace/' '
53
54 compare rev-parse "subspace/one subspace/two" "--glob=refs/heads/subspace/"
55
56'
57
58test_expect_success 'rev-parse --glob=heads/subspace/' '
59
60 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace/"
61
62'
63
64test_expect_success 'rev-parse --glob=heads/subspace' '
65
66 compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace"
67
68'
69
70test_expect_success 'rev-parse --branches=subspace/*' '
71
72 compare rev-parse "subspace/one subspace/two" "--branches=subspace/*"
73
74'
75
76test_expect_success 'rev-parse --branches=subspace/' '
77
78 compare rev-parse "subspace/one subspace/two" "--branches=subspace/"
79
80'
81
82test_expect_success 'rev-parse --branches=subspace' '
83
84 compare rev-parse "subspace/one subspace/two" "--branches=subspace"
85
86'
87
88test_expect_success 'rev-parse --glob=heads/subspace/* --glob=heads/other/*' '
89
90 compare rev-parse "subspace/one subspace/two other/three" "--glob=heads/subspace/* --glob=heads/other/*"
91
92'
93
94test_expect_success 'rev-parse --glob=heads/someref/* master' '
95
96 compare rev-parse "master" "--glob=heads/someref/* master"
97
98'
99
100test_expect_success 'rev-parse --glob=heads/*' '
101
102 compare rev-parse "master other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*"
103
104'
105
106test_expect_success 'rev-parse --tags=foo' '
107
108 compare rev-parse "foo/bar" "--tags=foo"
109
110'
111
112test_expect_success 'rev-parse --remotes=foo' '
113
114 compare rev-parse "foo/baz" "--remotes=foo"
115
116'
117
118test_expect_success 'rev-list --glob=refs/heads/subspace/*' '
119
120 compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/*"
121
122'
123
124test_expect_success 'rev-list --glob=heads/subspace/*' '
125
126 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/*"
127
128'
129
130test_expect_success 'rev-list --glob=refs/heads/subspace/' '
131
132 compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/"
133
134'
135
136test_expect_success 'rev-list --glob=heads/subspace/' '
137
138 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/"
139
140'
141
142test_expect_success 'rev-list --glob=heads/subspace' '
143
144 compare rev-list "subspace/one subspace/two" "--glob=heads/subspace"
145
146'
147
148test_expect_success 'rev-list --branches=subspace/*' '
149
150 compare rev-list "subspace/one subspace/two" "--branches=subspace/*"
151
152'
153
154test_expect_success 'rev-list --branches=subspace/' '
155
156 compare rev-list "subspace/one subspace/two" "--branches=subspace/"
157
158'
159
160test_expect_success 'rev-list --branches=subspace' '
161
162 compare rev-list "subspace/one subspace/two" "--branches=subspace"
163
164'
165test_expect_success 'rev-list --glob=heads/someref/* master' '
166
167 compare rev-list "master" "--glob=heads/someref/* master"
168
169'
170
171test_expect_success 'rev-list --glob=heads/subspace/* --glob=heads/other/*' '
172
173 compare rev-list "subspace/one subspace/two other/three" "--glob=heads/subspace/* --glob=heads/other/*"
174
175'
176
177test_expect_success 'rev-list --glob=heads/*' '
178
179 compare rev-list "master other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*"
180
181'
182
183test_expect_success 'rev-list --tags=foo' '
184
185 compare rev-list "foo/bar" "--tags=foo"
186
187'
188
189test_expect_success 'rev-list --remotes=foo' '
190
191 compare rev-list "foo/baz" "--remotes=foo"
192
193'
194
195test_done