Add FILTER_REFS_REMOTE_TAGS to allow tags to be to identified as a remote-tags and then list them without displaying refs/remote-tags. Signed-off-by: Wink Saville <wink@xxxxxxxxxxx> --- builtin/tag.c | 2 +- ref-filter.c | 9 +++++++-- ref-filter.h | 11 ++++++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/builtin/tag.c b/builtin/tag.c index 46a5c6a1da..9ac85f0ff8 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -57,7 +57,7 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting, if (verify_ref_format(format)) die(_("unable to parse format string")); filter->with_commit_tag_algo = 1; - filter_refs(&array, filter, FILTER_REFS_TAGS); + filter_refs(&array, filter, (FILTER_REFS_TAGS | FILTER_REFS_REMOTE_TAGS)); ref_array_sort(sorting, &array); for (i = 0; i < array.nr; i++) diff --git a/ref-filter.c b/ref-filter.c index ac82f9f21e..1fcaa2ea33 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -1682,6 +1682,7 @@ static int match_pattern(const struct ref_filter *filter, const char *refname) * for matching refs of tags and branches. */ (void)(skip_prefix(refname, "refs/tags/", &refname) || + skip_prefix(refname, "refs/remote-tags/", &refname) || skip_prefix(refname, "refs/heads/", &refname) || skip_prefix(refname, "refs/remotes/", &refname) || skip_prefix(refname, "refs/", &refname)); @@ -1866,7 +1867,8 @@ static int ref_kind_from_refname(const char *refname) } ref_kind[] = { { "refs/heads/" , FILTER_REFS_BRANCHES }, { "refs/remotes/" , FILTER_REFS_REMOTES }, - { "refs/tags/", FILTER_REFS_TAGS} + { "refs/tags/", FILTER_REFS_TAGS}, + { "refs/remote-tags/", FILTER_REFS_REMOTE_TAGS} }; if (!strcmp(refname, "HEAD")) @@ -1884,7 +1886,8 @@ static int filter_ref_kind(struct ref_filter *filter, const char *refname) { if (filter->kind == FILTER_REFS_BRANCHES || filter->kind == FILTER_REFS_REMOTES || - filter->kind == FILTER_REFS_TAGS) + filter->kind == FILTER_REFS_TAGS || + filter->kind == FILTER_REFS_REMOTE_TAGS) return filter->kind; return ref_kind_from_refname(refname); } @@ -2053,6 +2056,8 @@ int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int ret = for_each_fullref_in("refs/remotes/", ref_filter_handler, &ref_cbdata, broken); else if (filter->kind == FILTER_REFS_TAGS) ret = for_each_fullref_in("refs/tags/", ref_filter_handler, &ref_cbdata, broken); + else if (filter->kind == FILTER_REFS_REMOTE_TAGS) + ret = for_each_fullref_in("refs/remote-tags/", ref_filter_handler, &ref_cbdata, broken); else if (filter->kind & FILTER_REFS_ALL) ret = for_each_fullref_in_pattern(filter, ref_filter_handler, &ref_cbdata, broken); if (!ret && (filter->kind & FILTER_REFS_DETACHED_HEAD)) diff --git a/ref-filter.h b/ref-filter.h index 76cf87cb6c..8b8d725b37 100644 --- a/ref-filter.h +++ b/ref-filter.h @@ -15,12 +15,13 @@ #define FILTER_REFS_INCLUDE_BROKEN 0x0001 #define FILTER_REFS_TAGS 0x0002 -#define FILTER_REFS_BRANCHES 0x0004 -#define FILTER_REFS_REMOTES 0x0008 -#define FILTER_REFS_OTHERS 0x0010 +#define FILTER_REFS_REMOTE_TAGS 0x0004 +#define FILTER_REFS_BRANCHES 0x0008 +#define FILTER_REFS_REMOTES 0x0010 +#define FILTER_REFS_OTHERS 0x0020 #define FILTER_REFS_ALL (FILTER_REFS_TAGS | FILTER_REFS_BRANCHES | \ - FILTER_REFS_REMOTES | FILTER_REFS_OTHERS) -#define FILTER_REFS_DETACHED_HEAD 0x0020 + FILTER_REFS_REMOTES | FILTER_REFS_REMOTE_TAGS | FILTER_REFS_OTHERS) +#define FILTER_REFS_DETACHED_HEAD 0x0040 #define FILTER_REFS_KIND_MASK (FILTER_REFS_ALL | FILTER_REFS_DETACHED_HEAD) struct atom_value; -- 2.17.0.393.g4573f5e134