The command freely used optional option-argments for its -l and -n options. I think allowing "git tag -n xxx" without barfing was an error to begin with, but not supporting "git tag -l pattern" form is a serious regression. So this fixes the handling of -l to reinstate the original behaviour while detecting a user error "git tag -l pattern garbage", and adjusts tests that use "-n param" form to use "-nparam". Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> --- builtin-tag.c | 15 +++++++- t/t7004-tag.sh | 110 +++++++++++++++++++++++++------------------------------ 2 files changed, 63 insertions(+), 62 deletions(-) diff --git a/builtin-tag.c b/builtin-tag.c index 274901a..5213c62 100644 --- a/builtin-tag.c +++ b/builtin-tag.c @@ -371,7 +371,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix) int annotate = 0, sign = 0, force = 0, lines = 0, delete = 0, verify = 0; - char *list = NULL, *msgfile = NULL, *keyid = NULL; + const char *list = NULL, *msgfile = NULL, *keyid = NULL; const char *no_pattern = "NO_PATTERN"; struct msg_arg msg = { 0, STRBUF_INIT }; struct option options[] = { @@ -407,8 +407,19 @@ int cmd_tag(int argc, const char **argv, const char *prefix) if (sign) annotate = 1; - if (list) + if (list) { + /* + * This is unfortunate but requiring "git tag -lpattern" and not + * allowing "git tag -l pattern" is a serious regression. + */ + if (argc && list == no_pattern) { + list = argv[0]; + argc--; + } + if (argc) + die("extra argument after -l[pattern]: %s", argv[0]); return list_tags(list == no_pattern ? NULL : list, lines); + } if (delete) return for_each_tag_name(argv, delete_tag); if (verify) diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index 09d56e0..7f58038 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -491,25 +491,19 @@ test_expect_success \ echo "tag-one-line" >expect && git-tag -l | grep "^tag-one-line" >actual && git diff expect actual && - git-tag -n 0 -l | grep "^tag-one-line" >actual && + git-tag -n0 -l | grep "^tag-one-line" >actual && git diff expect actual && - git-tag -n 0 -l tag-one-line >actual && + git-tag -n0 -l tag-one-line >actual && 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 && git diff expect actual && - git-tag -n 1 -l tag-one-line >actual && + git-tag -n1 -l | grep "^tag-one-line" >actual && git diff expect actual && - git-tag -n 2 -l tag-one-line >actual && + git-tag -n2 -l tag-one-line >actual && git diff expect actual && - git-tag -n 999 -l tag-one-line >actual && + git-tag -n999 -l tag-one-line >actual && git diff expect actual ' @@ -520,21 +514,21 @@ test_expect_success \ echo "tag-zero-lines" >expect && git-tag -l | grep "^tag-zero-lines" >actual && git diff expect actual && - git-tag -n 0 -l | grep "^tag-zero-lines" >actual && + git-tag -n0 -l | grep "^tag-zero-lines" >actual && git diff expect actual && - git-tag -n 0 -l tag-zero-lines >actual && + git-tag -n0 -l tag-zero-lines >actual && git diff expect actual && echo "tag-zero-lines " >expect && - git-tag -n 1 -l | grep "^tag-zero-lines" >actual && + git-tag -n1 -l | grep "^tag-zero-lines" >actual && git diff expect actual && git-tag -n -l | grep "^tag-zero-lines" >actual && git diff expect actual && - git-tag -n 1 -l tag-zero-lines >actual && + git-tag -n1 -l tag-zero-lines >actual && git diff expect actual && - git-tag -n 2 -l tag-zero-lines >actual && + git-tag -n2 -l tag-zero-lines >actual && git diff expect actual && - git-tag -n 999 -l tag-zero-lines >actual && + git-tag -n999 -l tag-zero-lines >actual && git diff expect actual ' @@ -548,37 +542,37 @@ test_expect_success \ echo "tag-lines" >expect && git-tag -l | grep "^tag-lines" >actual && git diff expect actual && - git-tag -n 0 -l | grep "^tag-lines" >actual && + git-tag -n0 -l | grep "^tag-lines" >actual && git diff expect actual && - git-tag -n 0 -l tag-lines >actual && + git-tag -n0 -l tag-lines >actual && git diff expect actual && echo "tag-lines tag line one" >expect && - git-tag -n 1 -l | grep "^tag-lines" >actual && + git-tag -n1 -l | grep "^tag-lines" >actual && git diff expect actual && git-tag -n -l | grep "^tag-lines" >actual && git diff expect actual && - git-tag -n 1 -l tag-lines >actual && + git-tag -n1 -l tag-lines >actual && git diff expect actual && echo " tag line two" >>expect && - git-tag -n 2 -l | grep "^ *tag.line" >actual && + git-tag -n2 -l | grep "^ *tag.line" >actual && git diff expect actual && - git-tag -n 2 -l tag-lines >actual && + git-tag -n2 -l tag-lines >actual && git diff expect actual && echo " tag line three" >>expect && - git-tag -n 3 -l | grep "^ *tag.line" >actual && + git-tag -n3 -l | grep "^ *tag.line" >actual && git diff expect actual && - git-tag -n 3 -l tag-lines >actual && + git-tag -n3 -l tag-lines >actual && git diff expect actual && - git-tag -n 4 -l | grep "^ *tag.line" >actual && + git-tag -n4 -l | grep "^ *tag.line" >actual && git diff expect actual && - git-tag -n 4 -l tag-lines >actual && + git-tag -n4 -l tag-lines >actual && git diff expect actual && - git-tag -n 99 -l | grep "^ *tag.line" >actual && + git-tag -n99 -l | grep "^ *tag.line" >actual && git diff expect actual && - git-tag -n 99 -l tag-lines >actual && + git-tag -n99 -l tag-lines >actual && git diff expect actual ' @@ -906,25 +900,21 @@ test_expect_success \ echo "stag-one-line" >expect && git-tag -l | grep "^stag-one-line" >actual && git diff expect actual && - git-tag -n 0 -l | grep "^stag-one-line" >actual && + git-tag -n0 -l | grep "^stag-one-line" >actual && git diff expect actual && - git-tag -n 0 -l stag-one-line >actual && + git-tag -n0 -l stag-one-line >actual && 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 && git diff expect actual && - git-tag -n 1 -l stag-one-line >actual && + git-tag -n1 -l | grep "^stag-one-line" >actual && git diff expect actual && - git-tag -n 2 -l stag-one-line >actual && + git-tag -n1 -l stag-one-line >actual && git diff expect actual && - git-tag -n 999 -l stag-one-line >actual && + git-tag -n2 -l stag-one-line >actual && + git diff expect actual && + git-tag -n999 -l stag-one-line >actual && git diff expect actual ' @@ -935,21 +925,21 @@ test_expect_success \ echo "stag-zero-lines" >expect && git-tag -l | grep "^stag-zero-lines" >actual && git diff expect actual && - git-tag -n 0 -l | grep "^stag-zero-lines" >actual && + git-tag -n0 -l | grep "^stag-zero-lines" >actual && git diff expect actual && - git-tag -n 0 -l stag-zero-lines >actual && + git-tag -n0 -l stag-zero-lines >actual && git diff expect actual && echo "stag-zero-lines " >expect && - git-tag -n 1 -l | grep "^stag-zero-lines" >actual && - git diff expect actual && git-tag -n -l | grep "^stag-zero-lines" >actual && git diff expect actual && - git-tag -n 1 -l stag-zero-lines >actual && + git-tag -n1 -l | grep "^stag-zero-lines" >actual && + git diff expect actual && + git-tag -n1 -l stag-zero-lines >actual && git diff expect actual && - git-tag -n 2 -l stag-zero-lines >actual && + git-tag -n2 -l stag-zero-lines >actual && git diff expect actual && - git-tag -n 999 -l stag-zero-lines >actual && + git-tag -n999 -l stag-zero-lines >actual && git diff expect actual ' @@ -963,37 +953,37 @@ test_expect_success \ echo "stag-lines" >expect && git-tag -l | grep "^stag-lines" >actual && git diff expect actual && - git-tag -n 0 -l | grep "^stag-lines" >actual && + git-tag -n0 -l | grep "^stag-lines" >actual && git diff expect actual && - git-tag -n 0 -l stag-lines >actual && + git-tag -n0 -l stag-lines >actual && git diff expect actual && echo "stag-lines stag line one" >expect && - git-tag -n 1 -l | grep "^stag-lines" >actual && - git diff expect actual && git-tag -n -l | grep "^stag-lines" >actual && git diff expect actual && - git-tag -n 1 -l stag-lines >actual && + git-tag -n1 -l | grep "^stag-lines" >actual && + git diff expect actual && + git-tag -n1 -l stag-lines >actual && git diff expect actual && echo " stag line two" >>expect && - git-tag -n 2 -l | grep "^ *stag.line" >actual && + git-tag -n2 -l | grep "^ *stag.line" >actual && git diff expect actual && - git-tag -n 2 -l stag-lines >actual && + git-tag -n2 -l stag-lines >actual && git diff expect actual && echo " stag line three" >>expect && - git-tag -n 3 -l | grep "^ *stag.line" >actual && + git-tag -n3 -l | grep "^ *stag.line" >actual && git diff expect actual && - git-tag -n 3 -l stag-lines >actual && + git-tag -n3 -l stag-lines >actual && git diff expect actual && - git-tag -n 4 -l | grep "^ *stag.line" >actual && + git-tag -n4 -l | grep "^ *stag.line" >actual && git diff expect actual && - git-tag -n 4 -l stag-lines >actual && + git-tag -n4 -l stag-lines >actual && git diff expect actual && - git-tag -n 99 -l | grep "^ *stag.line" >actual && + git-tag -n99 -l | grep "^ *stag.line" >actual && git diff expect actual && - git-tag -n 99 -l stag-lines >actual && + git-tag -n99 -l stag-lines >actual && git diff expect actual ' -- 1.5.4.rc0.54.g3eb2 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html