|
16 | 16 | static const char * const git_tag_usage[] = {
|
17 | 17 | "git tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]",
|
18 | 18 | "git tag -d <tagname>...",
|
19 |
| - "git tag -l [-n[<num>]] [<pattern>]", |
| 19 | + "git tag -l [-n[<num>]] [<pattern>...]", |
20 | 20 | "git tag -v <tagname>...",
|
21 | 21 | NULL
|
22 | 22 | };
|
23 | 23 |
|
24 | 24 | static char signingkey[1000];
|
25 | 25 |
|
26 | 26 | struct tag_filter {
|
27 |
| - const char *pattern; |
| 27 | + const char **patterns; |
28 | 28 | int lines;
|
29 | 29 | struct commit_list *with_commit;
|
30 | 30 | };
|
31 | 31 |
|
| 32 | +static int match_pattern(const char **patterns, const char *ref) |
| 33 | +{ |
| 34 | + /* no pattern means match everything */ |
| 35 | + if (!*patterns) |
| 36 | + return 1; |
| 37 | + for (; *patterns; patterns++) |
| 38 | + if (!fnmatch(*patterns, ref, 0)) |
| 39 | + return 1; |
| 40 | + return 0; |
| 41 | +} |
| 42 | + |
32 | 43 | static int show_reference(const char *refname, const unsigned char *sha1,
|
33 | 44 | int flag, void *cb_data)
|
34 | 45 | {
|
35 | 46 | struct tag_filter *filter = cb_data;
|
36 | 47 |
|
37 |
| - if (!fnmatch(filter->pattern, refname, 0)) { |
| 48 | + if (match_pattern(filter->patterns, refname)) { |
38 | 49 | int i;
|
39 | 50 | unsigned long size;
|
40 | 51 | enum object_type type;
|
@@ -88,15 +99,12 @@ static int show_reference(const char *refname, const unsigned char *sha1,
|
88 | 99 | return 0;
|
89 | 100 | }
|
90 | 101 |
|
91 |
| -static int list_tags(const char *pattern, int lines, |
| 102 | +static int list_tags(const char **patterns, int lines, |
92 | 103 | struct commit_list *with_commit)
|
93 | 104 | {
|
94 | 105 | struct tag_filter filter;
|
95 | 106 |
|
96 |
| - if (pattern == NULL) |
97 |
| - pattern = "*"; |
98 |
| - |
99 |
| - filter.pattern = pattern; |
| 107 | + filter.patterns = patterns; |
100 | 108 | filter.lines = lines;
|
101 | 109 | filter.with_commit = with_commit;
|
102 | 110 |
|
@@ -425,7 +433,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
|
425 | 433 | if (list + delete + verify > 1)
|
426 | 434 | usage_with_options(git_tag_usage, options);
|
427 | 435 | if (list)
|
428 |
| - return list_tags(argv[0], lines == -1 ? 0 : lines, |
| 436 | + return list_tags(argv, lines == -1 ? 0 : lines, |
429 | 437 | with_commit);
|
430 | 438 | if (lines != -1)
|
431 | 439 | die(_("-n option is only allowed with -l."));
|
|
0 commit comments