Skip to content

Commit

Permalink
git-tag: fix -l switch handling regression.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
MadCoder authored and gitster committed Dec 22, 2007
1 parent 56c3eb1 commit 78d776a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
12 changes: 5 additions & 7 deletions builtin-tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 [-n [<num>]] -l [<pattern>]",
"git-tag -l [-n [<num>]] [<pattern>]",
"git-tag -v <tagname>...",
NULL
};
Expand Down Expand Up @@ -370,13 +370,11 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
struct ref_lock *lock;

int annotate = 0, sign = 0, force = 0, lines = 0,
delete = 0, verify = 0;
char *list = NULL, *msgfile = NULL, *keyid = NULL;
const char *no_pattern = "NO_PATTERN";
list = 0, delete = 0, verify = 0;
char *msgfile = NULL, *keyid = NULL;
struct msg_arg msg = { 0, STRBUF_INIT };
struct option options[] = {
{ OPTION_STRING, 'l', NULL, &list, "pattern", "list tag names",
PARSE_OPT_OPTARG, NULL, (intptr_t) no_pattern },
OPT_BOOLEAN('l', NULL, &list, "list tag names"),
{ OPTION_INTEGER, 'n', NULL, &lines, NULL,
"print n lines of each tag message",
PARSE_OPT_OPTARG, NULL, 1 },
Expand Down Expand Up @@ -408,7 +406,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
annotate = 1;

if (list)
return list_tags(list == no_pattern ? NULL : list, lines);
return list_tags(argv[0], lines);
if (delete)
return for_each_tag_name(argv, delete_tag);
if (verify)
Expand Down
8 changes: 0 additions & 8 deletions t/t7004-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,6 @@ test_expect_success \
git diff expect actual &&
echo "tag-one-line A msg" >expect &&
git-tag -n xxx -l | grep "^tag-one-line" >actual &&
git diff expect actual &&
git-tag -n "" -l | grep "^tag-one-line" >actual &&
git diff expect actual &&
git-tag -n 1 -l | grep "^tag-one-line" >actual &&
git diff expect actual &&
git-tag -n -l | grep "^tag-one-line" >actual &&
Expand Down Expand Up @@ -912,10 +908,6 @@ test_expect_success \
git diff expect actual &&
echo "stag-one-line A message line signed" >expect &&
git-tag -n xxx -l | grep "^stag-one-line" >actual &&
git diff expect actual &&
git-tag -n "" -l | grep "^stag-one-line" >actual &&
git diff expect actual &&
git-tag -n 1 -l | grep "^stag-one-line" >actual &&
git diff expect actual &&
git-tag -n -l | grep "^stag-one-line" >actual &&
Expand Down

0 comments on commit 78d776a

Please sign in to comment.