refs: show --exclude failure with --branches/tags/remotes=glob

The documentation of `--exclude=` option from rev-list and rev-parse explicitly states that exclude patterns *should not* start with 'refs/' when used with `--branches`, `--tags` or `--remotes`. However, following this advice results in refereces not being excluded if the next `--branches`, `--tags`, `--remotes` use the optional inclusive glob. Demonstrate this failure. Signed-off-by: Rafael Ascensão <rafa.almas@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Rafael Ascensão committed Nov 12, 2018 at 13:25 UTC 9d55dca262e8657b87dbd4c5b3494e1ecb7a0dbd
1 file changed +57 -3
t/t6018-rev-list-glob.sh
+57 -3
@@ -36,7 +36,13 @@ test_expect_success 'setup' '
36 git tag foo/bar master &&
37 commit master3 &&
38 git update-ref refs/remotes/foo/baz master &&
39 - commit master4
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
46 '
47
48 test_expect_success 'rev-parse --glob=refs/heads/subspace/*' '
@@ -141,6 +147,54 @@ test_expect_success 'rev-parse accumulates multiple --exclude' '
147 compare rev-parse "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches
148 '
149
150 +test_expect_failure 'rev-parse --exclude=glob with --branches=glob' '
151 + compare rev-parse "--exclude=subspace-* --branches=sub*" "subspace/one subspace/two"
152 +'
153 +
154 +test_expect_failure 'rev-parse --exclude=glob with --tags=glob' '
155 + compare rev-parse "--exclude=qux/? --tags=qux/*" "qux/one qux/two"
156 +'
157 +
158 +test_expect_failure 'rev-parse --exclude=glob with --remotes=glob' '
159 + compare rev-parse "--exclude=upstream/? --remotes=upstream/*" "upstream/one upstream/two"
160 +'
161 +
162 +test_expect_failure 'rev-parse --exclude=ref with --branches=glob' '
163 + compare rev-parse "--exclude=subspace-x --branches=sub*" "subspace/one subspace/two"
164 +'
165 +
166 +test_expect_failure 'rev-parse --exclude=ref with --tags=glob' '
167 + compare rev-parse "--exclude=qux/x --tags=qux/*" "qux/one qux/two"
168 +'
169 +
170 +test_expect_failure 'rev-parse --exclude=ref with --remotes=glob' '
171 + compare rev-parse "--exclude=upstream/x --remotes=upstream/*" "upstream/one upstream/two"
172 +'
173 +
174 +test_expect_failure 'rev-list --exclude=glob with --branches=glob' '
175 + compare rev-list "--exclude=subspace-* --branches=sub*" "subspace/one subspace/two"
176 +'
177 +
178 +test_expect_failure 'rev-list --exclude=glob with --tags=glob' '
179 + compare rev-list "--exclude=qux/? --tags=qux/*" "qux/one qux/two"
180 +'
181 +
182 +test_expect_failure 'rev-list --exclude=glob with --remotes=glob' '
183 + compare rev-list "--exclude=upstream/? --remotes=upstream/*" "upstream/one upstream/two"
184 +'
185 +
186 +test_expect_failure 'rev-list --exclude=ref with --branches=glob' '
187 + compare rev-list "--exclude=subspace-x --branches=sub*" "subspace/one subspace/two"
188 +'
189 +
190 +test_expect_failure 'rev-list --exclude=ref with --tags=glob' '
191 + compare rev-list "--exclude=qux/x --tags=qux/*" "qux/one qux/two"
192 +'
193 +
194 +test_expect_failure 'rev-list --exclude=ref with --remotes=glob' '
195 + compare rev-list "--exclude=upstream/x --remotes=upstream/*" "upstream/one upstream/two"
196 +'
197 +
198 test_expect_success 'rev-list --glob=refs/heads/subspace/*' '
199
200 compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/*"
@@ -233,7 +287,7 @@ test_expect_success 'rev-list --tags=foo' '
287
288 test_expect_success 'rev-list --tags' '
289
236 - compare rev-list "foo/bar" "--tags"
290 + compare rev-list "foo/bar qux/x qux/two qux/one" "--tags"
291
292 '
293
@@ -292,7 +346,7 @@ test_expect_success 'shortlog accepts --glob/--tags/--remotes' '
346 "master other/three someref subspace-x subspace/one subspace/two" \
347 "--glob=heads/*" &&
348 compare shortlog foo/bar --tags=foo &&
295 - compare shortlog foo/bar --tags &&
349 + compare shortlog "foo/bar qux/one qux/two qux/x" --tags &&
350 compare shortlog foo/baz --remotes=foo
351
352 '