aboutsummaryrefslogtreecommitdiffstats
path: root/refs.c
diff options
context:
space:
mode:
authorRafael Ascensão <rafa.almas@gmail.com>2018-11-12 13:25:44 +0000
committerJunio C Hamano <gitster@pobox.com>2018-11-13 14:41:22 +0900
commit9ab9b5df0ee2a49e0c1354a667e1e00db903f516 (patch)
tree12d807f4027241a66ecd1eba1bfb5b18affeb005 /refs.c
parent9d55dca262e8657b87dbd4c5b3494e1ecb7a0dbd (diff)
downloadgit-9ab9b5df0ee2a49e0c1354a667e1e00db903f516.tar.gz
refs: fix some exclude patterns being ignored
`--exclude` from rev-list and rev-parse fails to exclude references if the next `--branches`, `--tags` or `--remotes` use the optional inclusive glob because those options are implemented as particular cases of `--glob=`, which itself requires that exclude patterns begin with 'refs/'. But it makes sense for `--branches=glob` and friends to be aware that exclusions patterns for them shouldn't be 'refs/<type>/' prefixed, the same way exclude patterns for `--branches` and friends (without the optional glob) already are. Let's record in 'refs.c:struct ref_filter' which context the exclude pattern is tied to, so refs.c:filter_refs() can decide if it should ignore the prefix when trying to match. Signed-off-by: Rafael Ascensão <rafa.almas@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/refs.c b/refs.c
index de81c7be7c..539f385f61 100644
--- a/refs.c
+++ b/refs.c
@@ -217,6 +217,7 @@ char *resolve_refdup(const char *refname, int resolve_flags,
/* The argument to filter_refs */
struct ref_filter {
const char *pattern;
+ const char *prefix;
each_ref_fn *fn;
void *cb_data;
};
@@ -296,6 +297,8 @@ static int filter_refs(const char *refname, const struct object_id *oid,
if (wildmatch(filter->pattern, refname, 0))
return 0;
+ if (filter->prefix)
+ skip_prefix(refname, filter->prefix, &refname);
return filter->fn(refname, oid, flags, filter->cb_data);
}
@@ -458,6 +461,7 @@ int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,
}
filter.pattern = real_pattern.buf;
+ filter.prefix = prefix;
filter.fn = fn;
filter.cb_data = cb_data;
ret = for_each_ref(filter_refs, &filter);