{"thread":{"id":"16166","subject":"[PATCH 3/3] tag: Add more tests about mixing incompatible modes and options","startedAt":"2008-11-04T12:42:07Z","lastAt":"2008-11-04T23:11:10Z","messageCount":5,"participants":["Samuel Tardieu","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"94886","messageId":"20081104124207.18273.31679.stgit@arrakis.enst.fr","threadId":"16166","inReplyTo":null,"subject":"[PATCH 1/3] tag: Do not allow to call \"git tag\" in more than one operating mode","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2008-11-04T12:42:07Z","receivedAt":"2008-11-04T12:42:07Z","isPatch":true,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":"If \"git tag -d -l -v ...\" is called, only \"-l\" is honored, which is\narbitrary and wrong.\n\nThis patch checks that \"git tag\" knows in what mode it operates before\nperforming any operation.\n\nSigned-Off-By: Samuel Tardieu <sam@rfc1149.net>\n---\n builtin-tag.c |    9 ++++-----\n 1 files changed, 4 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin-tag.c b/builtin-tag.c\nindex 84db156..5ce0e21 100644\n--- a/builtin-tag.c\n+++ b/builtin-tag.c\n@@ -380,7 +380,11 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t}\n \tif (sign)\n \t\tannotate = 1;\n+\tif (argc == 0 && !(delete || verify))\n+\t\tlist = 1;\n \n+\tif (list + delete + verify > 1)\n+\t\tusage_with_options(git_tag_usage, options);\n \tif (list)\n \t\treturn list_tags(argv[0], lines);\n \tif (delete)\n@@ -406,11 +410,6 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\t}\n \t}\n \n-\tif (argc == 0) {\n-\t\tif (annotate)\n-\t\t\tusage_with_options(git_tag_usage, options);\n-\t\treturn list_tags(NULL, lines);\n-\t}\n \ttag = argv[0];\n \n \tobject_ref = argc == 2 ? argv[1] : \"HEAD\";\n"},{"id":"94887","messageId":"20081104124212.18273.5402.stgit@arrakis.enst.fr","threadId":"16166","inReplyTo":"20081104124207.18273.31679.stgit@arrakis.enst.fr","subject":"[PATCH 2/3] tag: Check that options are only allowed in the appropriate mode","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2008-11-04T12:42:12Z","receivedAt":"2008-11-04T12:42:12Z","isPatch":true,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":"\"git tag\" should not silently accept unrecognized options when operating\nin a given mode. For example, \"git tag -n 100\", which may be a typo for\n\"git tag -n100\", should not silently create a tag named \"100\".\n\nSigned-off-by: Samuel Tardieu <sam@rfc1149.net>\n---\n builtin-tag.c |   10 ++++++++--\n 1 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-tag.c b/builtin-tag.c\nindex 5ce0e21..d339971 100644\n--- a/builtin-tag.c\n+++ b/builtin-tag.c\n@@ -344,7 +344,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \tconst char *object_ref, *tag;\n \tstruct ref_lock *lock;\n \n-\tint annotate = 0, sign = 0, force = 0, lines = 0,\n+\tint annotate = 0, sign = 0, force = 0, lines = -1,\n \t\tlist = 0, delete = 0, verify = 0;\n \tconst char *msgfile = NULL, *keyid = NULL;\n \tstruct msg_arg msg = { 0, STRBUF_INIT };\n@@ -383,10 +383,16 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \tif (argc == 0 && !(delete || verify))\n \t\tlist = 1;\n \n+\tif ((annotate || msg.given || msgfile || force) &&\n+\t    (list || delete || verify))\n+\t\tusage_with_options(git_tag_usage, options);\n+\n \tif (list + delete + verify > 1)\n \t\tusage_with_options(git_tag_usage, options);\n \tif (list)\n-\t\treturn list_tags(argv[0], lines);\n+\t\treturn list_tags(argv[0], lines == -1 ? 0 : lines);\n+\tif (lines != -1)\n+\t\tdie(\"-n option is only allowed with -l.\");\n \tif (delete)\n \t\treturn for_each_tag_name(argv, delete_tag);\n \tif (verify)\n"},{"id":"94885","messageId":"20081104124217.18273.40967.stgit@arrakis.enst.fr","threadId":"16166","inReplyTo":"20081104124207.18273.31679.stgit@arrakis.enst.fr","subject":"[PATCH 3/3] tag: Add more tests about mixing incompatible modes and options","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2008-11-04T12:42:17Z","receivedAt":"2008-11-04T12:42:17Z","isPatch":true,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":"Signed-Off-By: Samuel Tardieu <sam@rfc1149.net>\n---\n t/t7004-tag.sh |   11 +++++++++++\n 1 files changed, 11 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex f0edbf1..f377fea 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -1090,4 +1090,15 @@ test_expect_success 'filename for the message is relative to cwd' '\n \tgit cat-file tag tag-from-subdir-2 | grep \"in sub directory\"\n '\n \n+# mixing modes and options:\n+\n+test_expect_success 'mixing incompatibles modes and options is forbidden' '\n+\ttest_must_fail git tag -a\n+\ttest_must_fail git tag -l -v\n+\ttest_must_fail git tag -n 100\n+\ttest_must_fail git tag -l -m msg\n+\ttest_must_fail git tag -l -F some file\n+\ttest_must_fail git tag -v -s\n+'\n+\n test_done\n"},{"id":"94925","messageId":"7vej1rqfar.fsf@gitster.siamese.dyndns.org","threadId":"16166","inReplyTo":"20081104124207.18273.31679.stgit@arrakis.enst.fr","subject":"Re: [PATCH 1/3] tag: Do not allow to call \"git tag\" in more than one operating mode","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-04T22:47:40Z","receivedAt":"2008-11-04T22:47:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Samuel Tardieu <sam@rfc1149.net> writes:\n\n> If \"git tag -d -l -v ...\" is called, only \"-l\" is honored, which is\n> arbitrary and wrong.\n>\n> This patch checks that \"git tag\" knows in what mode it operates before\n> performing any operation.\n>\n> Signed-Off-By: Samuel Tardieu <sam@rfc1149.net>\n\ns/-Off-B/off-b/;\n\nI think this patch breaks \"git tag -a\" or \"git tag -s\", but I didn't try.\nRun\n\n\t$ git tag -s\n\nwith and without your patch.\n"},{"id":"94930","messageId":"2008-11-05-00-11-10+trackit+sam@rfc1149.net","threadId":"16166","inReplyTo":"7vej1rqfar.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 1/3] tag: Do not allow to call \"git tag\" in more than one operating mode","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2008-11-04T23:11:10Z","receivedAt":"2008-11-04T23:11:10Z","isPatch":true,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":"* Junio C Hamano <gitster@pobox.com> [2008-11-04 14:47:40 -0800]\n\n| I think this patch breaks \"git tag -a\" or \"git tag -s\", but I didn't try.\n| Run\n| \n| \t$ git tag -s\n| \n| with and without your patch.\n\nThat's right. I didn't notice it because I developped the 2/3 at\nthe same time and tested with both applied at the same time.\n\nI will resubmit the serie with the first two merged together,\nas they are both short, on the same topic and fix the same\nproblem.\n"}]}