summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-08-16 19:41:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-08-16 19:41:14 (GMT)
commit1f2705e20fa5f2d3c93663296eef723f45d1fa41 (patch)
treeb8dcaa8a4a860c640058401b51ced3abbcba2630 /builtin
parent1320352501a73a91d77b7865993f322026d056d7 (diff)
parent588d0e834b244565863fa80e6c48c20e0db9b62f (diff)
downloadgit-1f2705e20fa5f2d3c93663296eef723f45d1fa41.zip
git-1f2705e20fa5f2d3c93663296eef723f45d1fa41.tar.gz
git-1f2705e20fa5f2d3c93663296eef723f45d1fa41.tar.bz2
Merge branch 'jk/tag-list-multiple-patterns' into maint
* jk/tag-list-multiple-patterns: tag: accept multiple patterns for --list
Diffstat (limited to 'builtin')
-rw-r--r--builtin/tag.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/builtin/tag.c b/builtin/tag.c
index ec926fc..cef2726 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -16,7 +16,7 @@
static const char * const git_tag_usage[] = {
"git tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]",
"git tag -d <tagname>...",
- "git tag -l [-n[<num>]] [<pattern>]",
+ "git tag -l [-n[<num>]] [<pattern>...]",
"git tag -v <tagname>...",
NULL
};
@@ -24,17 +24,28 @@ static const char * const git_tag_usage[] = {
static char signingkey[1000];
struct tag_filter {
- const char *pattern;
+ const char **patterns;
int lines;
struct commit_list *with_commit;
};
+static int match_pattern(const char **patterns, const char *ref)
+{
+ /* no pattern means match everything */
+ if (!*patterns)
+ return 1;
+ for (; *patterns; patterns++)
+ if (!fnmatch(*patterns, ref, 0))
+ return 1;
+ return 0;
+}
+
static int show_reference(const char *refname, const unsigned char *sha1,
int flag, void *cb_data)
{
struct tag_filter *filter = cb_data;
- if (!fnmatch(filter->pattern, refname, 0)) {
+ if (match_pattern(filter->patterns, refname)) {
int i;
unsigned long size;
enum object_type type;
@@ -88,15 +99,12 @@ static int show_reference(const char *refname, const unsigned char *sha1,
return 0;
}
-static int list_tags(const char *pattern, int lines,
+static int list_tags(const char **patterns, int lines,
struct commit_list *with_commit)
{
struct tag_filter filter;
- if (pattern == NULL)
- pattern = "*";
-
- filter.pattern = pattern;
+ filter.patterns = patterns;
filter.lines = lines;
filter.with_commit = with_commit;
@@ -425,7 +433,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
if (list + delete + verify > 1)
usage_with_options(git_tag_usage, options);
if (list)
- return list_tags(argv[0], lines == -1 ? 0 : lines,
+ return list_tags(argv, lines == -1 ? 0 : lines,
with_commit);
if (lines != -1)
die(_("-n option is only allowed with -l."));