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