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>
Pierre Habouzit committed
Dec 21, 2007 at 11:50 UTC
78d776a9699cd3e3d368366afaa66dee97e53ac5
2 files changed
+5
-15
builtin-tag.c
+5
-7
@@ -16,7 +16,7 @@
16
static const char * const git_tag_usage[] = {
17
"git-tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]",
18
"git-tag -d <tagname>...",
19
- "git-tag [-n [<num>]] -l [<pattern>]",
19
+ "git-tag -l [-n [<num>]] [<pattern>]",
20
"git-tag -v <tagname>...",
21
NULL
22
};
@@ -370,13 +370,11 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
370
struct ref_lock *lock;
371
372
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;
375
struct msg_arg msg = { 0, STRBUF_INIT };
376
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"),
378
{ OPTION_INTEGER, 'n', NULL, &lines, NULL,
379
"print n lines of each tag message",
380
PARSE_OPT_OPTARG, NULL, 1 },
@@ -408,7 +406,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
406
annotate = 1;
407
408
if (list)
411
- return list_tags(list == no_pattern ? NULL : list, lines);
409
+ return list_tags(argv[0], lines);
410
if (delete)
411
return for_each_tag_name(argv, delete_tag);
412
if (verify)
t/t7004-tag.sh
-8
@@ -497,10 +497,6 @@ test_expect_success \
497
git diff expect actual &&
498
499
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 &&
500
git-tag -n 1 -l | grep "^tag-one-line" >actual &&
501
git diff expect actual &&
502
git-tag -n -l | grep "^tag-one-line" >actual &&
@@ -912,10 +908,6 @@ test_expect_success \
908
git diff expect actual &&
909
910
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 &&
911
git-tag -n 1 -l | grep "^stag-one-line" >actual &&
912
git diff expect actual &&
913
git-tag -n -l | grep "^stag-one-line" >actual &&