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