]>
Commit | Line | Data |
---|---|---|
d08bae7e IL |
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 && | |
b09fe971 IL |
35 | commit master2 && |
36 | git tag foo/bar master && | |
52663475 MG |
37 | commit master3 && |
38 | git update-ref refs/remotes/foo/baz master && | |
9d55dca2 RA |
39 | commit master4 && |
40 | git update-ref refs/remotes/upstream/one subspace/one && | |
41 | git update-ref refs/remotes/upstream/two subspace/two && | |
42 | git update-ref refs/remotes/upstream/x subspace-x && | |
43 | git tag qux/one subspace/one && | |
44 | git tag qux/two subspace/two && | |
45 | git tag qux/x subspace-x | |
d08bae7e IL |
46 | ' |
47 | ||
48 | test_expect_success 'rev-parse --glob=refs/heads/subspace/*' ' | |
49 | ||
50 | compare rev-parse "subspace/one subspace/two" "--glob=refs/heads/subspace/*" | |
51 | ||
52 | ' | |
53 | ||
54 | test_expect_success 'rev-parse --glob=heads/subspace/*' ' | |
55 | ||
56 | compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace/*" | |
57 | ||
58 | ' | |
59 | ||
60 | test_expect_success 'rev-parse --glob=refs/heads/subspace/' ' | |
61 | ||
62 | compare rev-parse "subspace/one subspace/two" "--glob=refs/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 --glob=heads/subspace' ' | |
73 | ||
74 | compare rev-parse "subspace/one subspace/two" "--glob=heads/subspace" | |
75 | ||
76 | ' | |
77 | ||
0fc63ec4 JN |
78 | test_expect_failure 'rev-parse accepts --glob as detached option' ' |
79 | ||
80 | compare rev-parse "subspace/one subspace/two" "--glob heads/subspace" | |
81 | ||
82 | ' | |
83 | ||
84 | test_expect_failure 'rev-parse is not confused by option-like glob' ' | |
85 | ||
86 | compare rev-parse "master" "--glob --symbolic master" | |
87 | ||
88 | ' | |
89 | ||
b09fe971 IL |
90 | test_expect_success 'rev-parse --branches=subspace/*' ' |
91 | ||
92 | compare rev-parse "subspace/one subspace/two" "--branches=subspace/*" | |
93 | ||
94 | ' | |
95 | ||
96 | test_expect_success 'rev-parse --branches=subspace/' ' | |
97 | ||
98 | compare rev-parse "subspace/one subspace/two" "--branches=subspace/" | |
99 | ||
100 | ' | |
101 | ||
102 | test_expect_success 'rev-parse --branches=subspace' ' | |
103 | ||
104 | compare rev-parse "subspace/one subspace/two" "--branches=subspace" | |
105 | ||
106 | ' | |
107 | ||
d08bae7e IL |
108 | test_expect_success 'rev-parse --glob=heads/subspace/* --glob=heads/other/*' ' |
109 | ||
110 | compare rev-parse "subspace/one subspace/two other/three" "--glob=heads/subspace/* --glob=heads/other/*" | |
111 | ||
112 | ' | |
113 | ||
114 | test_expect_success 'rev-parse --glob=heads/someref/* master' ' | |
115 | ||
116 | compare rev-parse "master" "--glob=heads/someref/* master" | |
117 | ||
118 | ' | |
119 | ||
120 | test_expect_success 'rev-parse --glob=heads/*' ' | |
121 | ||
122 | compare rev-parse "master other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*" | |
123 | ||
124 | ' | |
125 | ||
b09fe971 IL |
126 | test_expect_success 'rev-parse --tags=foo' ' |
127 | ||
128 | compare rev-parse "foo/bar" "--tags=foo" | |
129 | ||
130 | ' | |
131 | ||
132 | test_expect_success 'rev-parse --remotes=foo' ' | |
133 | ||
134 | compare rev-parse "foo/baz" "--remotes=foo" | |
135 | ||
136 | ' | |
137 | ||
9dc01bf0 JH |
138 | test_expect_success 'rev-parse --exclude with --branches' ' |
139 | compare rev-parse "--exclude=*/* --branches" "master someref subspace-x" | |
140 | ' | |
141 | ||
142 | test_expect_success 'rev-parse --exclude with --all' ' | |
143 | compare rev-parse "--exclude=refs/remotes/* --all" "--branches --tags" | |
144 | ' | |
145 | ||
146 | test_expect_success 'rev-parse accumulates multiple --exclude' ' | |
147 | compare rev-parse "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches | |
148 | ' | |
149 | ||
52210480 AG |
150 | test_expect_success 'rev-parse --branches clears --exclude' ' |
151 | compare rev-parse "--exclude=* --branches --branches" "--branches" | |
152 | ' | |
153 | ||
154 | test_expect_success 'rev-parse --tags clears --exclude' ' | |
155 | compare rev-parse "--exclude=* --tags --tags" "--tags" | |
156 | ' | |
157 | ||
158 | test_expect_success 'rev-parse --all clears --exclude' ' | |
159 | compare rev-parse "--exclude=* --all --all" "--all" | |
160 | ' | |
161 | ||
9ab9b5df | 162 | test_expect_success 'rev-parse --exclude=glob with --branches=glob' ' |
9d55dca2 RA |
163 | compare rev-parse "--exclude=subspace-* --branches=sub*" "subspace/one subspace/two" |
164 | ' | |
165 | ||
9ab9b5df | 166 | test_expect_success 'rev-parse --exclude=glob with --tags=glob' ' |
9d55dca2 RA |
167 | compare rev-parse "--exclude=qux/? --tags=qux/*" "qux/one qux/two" |
168 | ' | |
169 | ||
9ab9b5df | 170 | test_expect_success 'rev-parse --exclude=glob with --remotes=glob' ' |
9d55dca2 RA |
171 | compare rev-parse "--exclude=upstream/? --remotes=upstream/*" "upstream/one upstream/two" |
172 | ' | |
173 | ||
9ab9b5df | 174 | test_expect_success 'rev-parse --exclude=ref with --branches=glob' ' |
9d55dca2 RA |
175 | compare rev-parse "--exclude=subspace-x --branches=sub*" "subspace/one subspace/two" |
176 | ' | |
177 | ||
9ab9b5df | 178 | test_expect_success 'rev-parse --exclude=ref with --tags=glob' ' |
9d55dca2 RA |
179 | compare rev-parse "--exclude=qux/x --tags=qux/*" "qux/one qux/two" |
180 | ' | |
181 | ||
9ab9b5df | 182 | test_expect_success 'rev-parse --exclude=ref with --remotes=glob' ' |
9d55dca2 RA |
183 | compare rev-parse "--exclude=upstream/x --remotes=upstream/*" "upstream/one upstream/two" |
184 | ' | |
185 | ||
9ab9b5df | 186 | test_expect_success 'rev-list --exclude=glob with --branches=glob' ' |
9d55dca2 RA |
187 | compare rev-list "--exclude=subspace-* --branches=sub*" "subspace/one subspace/two" |
188 | ' | |
189 | ||
9ab9b5df | 190 | test_expect_success 'rev-list --exclude=glob with --tags=glob' ' |
9d55dca2 RA |
191 | compare rev-list "--exclude=qux/? --tags=qux/*" "qux/one qux/two" |
192 | ' | |
193 | ||
9ab9b5df | 194 | test_expect_success 'rev-list --exclude=glob with --remotes=glob' ' |
9d55dca2 RA |
195 | compare rev-list "--exclude=upstream/? --remotes=upstream/*" "upstream/one upstream/two" |
196 | ' | |
197 | ||
9ab9b5df | 198 | test_expect_success 'rev-list --exclude=ref with --branches=glob' ' |
9d55dca2 RA |
199 | compare rev-list "--exclude=subspace-x --branches=sub*" "subspace/one subspace/two" |
200 | ' | |
201 | ||
9ab9b5df | 202 | test_expect_success 'rev-list --exclude=ref with --tags=glob' ' |
9d55dca2 RA |
203 | compare rev-list "--exclude=qux/x --tags=qux/*" "qux/one qux/two" |
204 | ' | |
205 | ||
9ab9b5df | 206 | test_expect_success 'rev-list --exclude=ref with --remotes=glob' ' |
9d55dca2 RA |
207 | compare rev-list "--exclude=upstream/x --remotes=upstream/*" "upstream/one upstream/two" |
208 | ' | |
209 | ||
d08bae7e IL |
210 | test_expect_success 'rev-list --glob=refs/heads/subspace/*' ' |
211 | ||
212 | compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/*" | |
213 | ||
214 | ' | |
215 | ||
5adba90d MM |
216 | test_expect_success 'rev-list --glob refs/heads/subspace/*' ' |
217 | ||
218 | compare rev-list "subspace/one subspace/two" "--glob refs/heads/subspace/*" | |
219 | ||
220 | ' | |
221 | ||
0fc63ec4 JN |
222 | test_expect_success 'rev-list not confused by option-like --glob arg' ' |
223 | ||
224 | compare rev-list "master" "--glob -0 master" | |
225 | ||
226 | ' | |
227 | ||
d08bae7e IL |
228 | test_expect_success 'rev-list --glob=heads/subspace/*' ' |
229 | ||
230 | compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/*" | |
231 | ||
232 | ' | |
233 | ||
234 | test_expect_success 'rev-list --glob=refs/heads/subspace/' ' | |
235 | ||
236 | compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/" | |
237 | ||
238 | ' | |
239 | ||
240 | test_expect_success 'rev-list --glob=heads/subspace/' ' | |
241 | ||
242 | compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/" | |
243 | ||
244 | ' | |
245 | ||
246 | test_expect_success 'rev-list --glob=heads/subspace' ' | |
247 | ||
248 | compare rev-list "subspace/one subspace/two" "--glob=heads/subspace" | |
249 | ||
250 | ' | |
251 | ||
b09fe971 IL |
252 | test_expect_success 'rev-list --branches=subspace/*' ' |
253 | ||
254 | compare rev-list "subspace/one subspace/two" "--branches=subspace/*" | |
255 | ||
256 | ' | |
257 | ||
258 | test_expect_success 'rev-list --branches=subspace/' ' | |
259 | ||
260 | compare rev-list "subspace/one subspace/two" "--branches=subspace/" | |
261 | ||
262 | ' | |
263 | ||
264 | test_expect_success 'rev-list --branches=subspace' ' | |
265 | ||
266 | compare rev-list "subspace/one subspace/two" "--branches=subspace" | |
267 | ||
268 | ' | |
9332441d MG |
269 | |
270 | test_expect_success 'rev-list --branches' ' | |
271 | ||
272 | compare rev-list "master subspace-x someref other/three subspace/one subspace/two" "--branches" | |
273 | ||
274 | ' | |
275 | ||
d08bae7e IL |
276 | test_expect_success 'rev-list --glob=heads/someref/* master' ' |
277 | ||
278 | compare rev-list "master" "--glob=heads/someref/* master" | |
279 | ||
280 | ' | |
281 | ||
282 | test_expect_success 'rev-list --glob=heads/subspace/* --glob=heads/other/*' ' | |
283 | ||
284 | compare rev-list "subspace/one subspace/two other/three" "--glob=heads/subspace/* --glob=heads/other/*" | |
285 | ||
286 | ' | |
287 | ||
288 | test_expect_success 'rev-list --glob=heads/*' ' | |
289 | ||
290 | compare rev-list "master other/three someref subspace-x subspace/one subspace/two" "--glob=heads/*" | |
291 | ||
292 | ' | |
293 | ||
b09fe971 IL |
294 | test_expect_success 'rev-list --tags=foo' ' |
295 | ||
296 | compare rev-list "foo/bar" "--tags=foo" | |
297 | ||
298 | ' | |
299 | ||
9332441d MG |
300 | test_expect_success 'rev-list --tags' ' |
301 | ||
9d55dca2 | 302 | compare rev-list "foo/bar qux/x qux/two qux/one" "--tags" |
9332441d MG |
303 | |
304 | ' | |
305 | ||
b09fe971 IL |
306 | test_expect_success 'rev-list --remotes=foo' ' |
307 | ||
308 | compare rev-list "foo/baz" "--remotes=foo" | |
309 | ||
310 | ' | |
311 | ||
751a2ac6 JH |
312 | test_expect_success 'rev-list --exclude with --branches' ' |
313 | compare rev-list "--exclude=*/* --branches" "master someref subspace-x" | |
314 | ' | |
315 | ||
316 | test_expect_success 'rev-list --exclude with --all' ' | |
317 | compare rev-list "--exclude=refs/remotes/* --all" "--branches --tags" | |
318 | ' | |
319 | ||
320 | test_expect_success 'rev-list accumulates multiple --exclude' ' | |
321 | compare rev-list "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches | |
322 | ' | |
323 | ||
a12cbe23 | 324 | test_expect_success 'rev-list should succeed with empty output on empty stdin' ' |
b89b4a66 | 325 | git rev-list --stdin </dev/null >actual && |
d3c6751b | 326 | test_must_be_empty actual |
751a2ac6 JH |
327 | ' |
328 | ||
0159ba32 | 329 | test_expect_success 'rev-list should succeed with empty output with all refs excluded' ' |
751a2ac6 | 330 | git rev-list --exclude=* --all >actual && |
d3c6751b | 331 | test_must_be_empty actual |
751a2ac6 JH |
332 | ' |
333 | ||
0159ba32 | 334 | test_expect_success 'rev-list should succeed with empty output with empty --all' ' |
751a2ac6 JH |
335 | ( |
336 | test_create_repo empty && | |
337 | cd empty && | |
751a2ac6 | 338 | git rev-list --all >actual && |
d3c6751b | 339 | test_must_be_empty actual |
751a2ac6 JH |
340 | ) |
341 | ' | |
342 | ||
0159ba32 | 343 | test_expect_success 'rev-list should succeed with empty output with empty glob' ' |
0c5dc743 | 344 | git rev-list --glob=does-not-match-anything >actual && |
d3c6751b | 345 | test_must_be_empty actual |
0c5dc743 JK |
346 | ' |
347 | ||
0fc63ec4 JN |
348 | test_expect_success 'shortlog accepts --glob/--tags/--remotes' ' |
349 | ||
350 | compare shortlog "subspace/one subspace/two" --branches=subspace && | |
351 | compare shortlog \ | |
352 | "master subspace-x someref other/three subspace/one subspace/two" \ | |
353 | --branches && | |
354 | compare shortlog master "--glob=heads/someref/* master" && | |
355 | compare shortlog "subspace/one subspace/two other/three" \ | |
356 | "--glob=heads/subspace/* --glob=heads/other/*" && | |
357 | compare shortlog \ | |
358 | "master other/three someref subspace-x subspace/one subspace/two" \ | |
359 | "--glob=heads/*" && | |
360 | compare shortlog foo/bar --tags=foo && | |
9d55dca2 | 361 | compare shortlog "foo/bar qux/one qux/two qux/x" --tags && |
0fc63ec4 JN |
362 | compare shortlog foo/baz --remotes=foo |
363 | ||
364 | ' | |
365 | ||
366 | test_expect_failure 'shortlog accepts --glob as detached option' ' | |
367 | ||
368 | compare shortlog \ | |
369 | "master other/three someref subspace-x subspace/one subspace/two" \ | |
370 | "--glob heads/*" | |
371 | ||
372 | ' | |
373 | ||
374 | test_expect_failure 'shortlog --glob is not confused by option-like argument' ' | |
375 | ||
376 | compare shortlog master "--glob -e master" | |
377 | ||
378 | ' | |
379 | ||
d08bae7e | 380 | test_done |