Skip to content

Commit 78d776a

Browse files
MadCodergitster
authored andcommitted
git-tag: fix -l switch handling regression.
The command itself takes an optional <pattern> argument that limits the shown tags to the ones that match when in listing mode that is triggered with '-l' option. The <pattern> is not an optional option-argument to '-l'. With this fix, "git tag -l -n 4 v0.99" works as expected. It also removes a few bogus tests in t7004. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 56c3eb1 commit 78d776a

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

builtin-tag.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
static const char * const git_tag_usage[] = {
1717
"git-tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]",
1818
"git-tag -d <tagname>...",
19-
"git-tag [-n [<num>]] -l [<pattern>]",
19+
"git-tag -l [-n [<num>]] [<pattern>]",
2020
"git-tag -v <tagname>...",
2121
NULL
2222
};
@@ -370,13 +370,11 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
370370
struct ref_lock *lock;
371371

372372
int annotate = 0, sign = 0, force = 0, lines = 0,
373-
delete = 0, verify = 0;
374-
char *list = NULL, *msgfile = NULL, *keyid = NULL;
375-
const char *no_pattern = "NO_PATTERN";
373+
list = 0, delete = 0, verify = 0;
374+
char *msgfile = NULL, *keyid = NULL;
376375
struct msg_arg msg = { 0, STRBUF_INIT };
377376
struct option options[] = {
378-
{ OPTION_STRING, 'l', NULL, &list, "pattern", "list tag names",
379-
PARSE_OPT_OPTARG, NULL, (intptr_t) no_pattern },
377+
OPT_BOOLEAN('l', NULL, &list, "list tag names"),
380378
{ OPTION_INTEGER, 'n', NULL, &lines, NULL,
381379
"print n lines of each tag message",
382380
PARSE_OPT_OPTARG, NULL, 1 },
@@ -408,7 +406,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
408406
annotate = 1;
409407

410408
if (list)
411-
return list_tags(list == no_pattern ? NULL : list, lines);
409+
return list_tags(argv[0], lines);
412410
if (delete)
413411
return for_each_tag_name(argv, delete_tag);
414412
if (verify)

t/t7004-tag.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,6 @@ test_expect_success \
497497
git diff expect actual &&
498498
499499
echo "tag-one-line A msg" >expect &&
500-
git-tag -n xxx -l | grep "^tag-one-line" >actual &&
501-
git diff expect actual &&
502-
git-tag -n "" -l | grep "^tag-one-line" >actual &&
503-
git diff expect actual &&
504500
git-tag -n 1 -l | grep "^tag-one-line" >actual &&
505501
git diff expect actual &&
506502
git-tag -n -l | grep "^tag-one-line" >actual &&
@@ -912,10 +908,6 @@ test_expect_success \
912908
git diff expect actual &&
913909
914910
echo "stag-one-line A message line signed" >expect &&
915-
git-tag -n xxx -l | grep "^stag-one-line" >actual &&
916-
git diff expect actual &&
917-
git-tag -n "" -l | grep "^stag-one-line" >actual &&
918-
git diff expect actual &&
919911
git-tag -n 1 -l | grep "^stag-one-line" >actual &&
920912
git diff expect actual &&
921913
git-tag -n -l | grep "^stag-one-line" >actual &&

0 commit comments

Comments
 (0)