{"thread":{"id":"28931","subject":"[PATCH] tag: implement --no-strip option","startedAt":"2011-11-14T11:08:22Z","lastAt":"2011-11-14T20:26:17Z","messageCount":2,"participants":["Kirill A. Shutemov","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"179419","messageId":"1321268902-2170-1-git-send-email-kirill@shutemov.name","threadId":"28931","inReplyTo":null,"subject":"[PATCH] tag: implement --no-strip option","fromName":"Kirill A. Shutemov","fromEmail":"kirill@shutemov.name","sentAt":"2011-11-14T11:08:22Z","receivedAt":"2011-11-14T11:08:22Z","isPatch":true,"sender":{"key":"kirill@shutemov.name","avatar":"https://avatars.githubusercontent.com/u/588661?v=4"},"body":"From: \"Kirill A. Shutemov\" <kirill@shutemov.name>\n\n--no-strip turns off strip any comments or empty lines.\n\nIt's useful if you want to take a tag message as-is, without any\nstripping.\n\nSigned-off-by: Kirill A. Shutemov <kirill@shutemov.name>\n---\n Documentation/git-tag.txt |    4 ++++\n builtin/tag.c             |   13 ++++++++-----\n 2 files changed, 12 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex c83cb13..947d4e5 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -99,6 +99,10 @@ OPTIONS\n \tImplies `-a` if none of `-a`, `-s`, or `-u <key-id>`\n \tis given.\n \n+-S::\n+--no-strip::\n+\tTake tag message as-is. Do not strip any comments or empty lines.\n+\n <tagname>::\n \tThe name of the tag to create, delete, or describe.\n \tThe new tag name must pass all checks defined by\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 9b6fd95..427d646 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -320,7 +320,7 @@ static int build_tag_object(struct strbuf *buf, int sign, unsigned char *result)\n }\n \n static void create_tag(const unsigned char *object, const char *tag,\n-\t\t       struct strbuf *buf, int message, int sign,\n+\t\t       struct strbuf *buf, int message, int sign, int nostrip,\n \t\t       unsigned char *prev, unsigned char *result)\n {\n \tenum object_type type;\n@@ -356,7 +356,7 @@ static void create_tag(const unsigned char *object, const char *tag,\n \n \t\tif (!is_null_sha1(prev))\n \t\t\twrite_tag_body(fd, prev);\n-\t\telse\n+\t\telse if (!nostrip)\n \t\t\twrite_or_die(fd, _(tag_template), strlen(_(tag_template)));\n \t\tclose(fd);\n \n@@ -367,7 +367,8 @@ static void create_tag(const unsigned char *object, const char *tag,\n \t\t}\n \t}\n \n-\tstripspace(buf, 1);\n+\tif (!nostrip)\n+\t\tstripspace(buf, 1);\n \n \tif (!message && !buf->len)\n \t\tdie(_(\"no tag message?\"));\n@@ -423,7 +424,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 = -1,\n+\tint annotate = 0, sign = 0, nostrip = 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@@ -443,6 +444,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\t\t     \"tag message\", parse_msg_arg),\n \t\tOPT_FILENAME('F', \"file\", &msgfile, \"read message from file\"),\n \t\tOPT_BOOLEAN('s', \"sign\", &sign, \"annotated and GPG-signed tag\"),\n+\t\tOPT_BOOLEAN('S', \"no-strip\", &nostrip,\n+\t\t\t\t\t\"turn off tag message stripping\"),\n \t\tOPT_STRING('u', \"local-user\", &keyid, \"key-id\",\n \t\t\t\t\t\"use another key to sign the tag\"),\n \t\tOPT__FORCE(&force, \"replace the tag if exists\"),\n@@ -525,7 +528,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \n \tif (annotate)\n \t\tcreate_tag(object, tag, &buf, msg.given || msgfile,\n-\t\t\t   sign, prev, object);\n+\t\t\t   sign, nostrip, prev, object);\n \n \tlock = lock_any_ref_for_update(ref.buf, prev, 0);\n \tif (!lock)\n-- \n1.7.7.2\n"},{"id":"179442","messageId":"7v7h32jvrq.fsf@alter.siamese.dyndns.org","threadId":"28931","inReplyTo":"1321268902-2170-1-git-send-email-kirill@shutemov.name","subject":"Re: [PATCH] tag: implement --no-strip option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-11-14T20:26:17Z","receivedAt":"2011-11-14T20:26:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kirill A. Shutemov\" <kirill@shutemov.name> writes:\n\n> +-S::\n> +--no-strip::\n> +\tTake tag message as-is. Do not strip any comments or empty lines.\n\nWrong naming convention.  Just introduce a boolean --strip option which is\non by default, without adding -S; use of parse-options will allow the user\nto negate it from the command line with --no-strip for free.\n\n> diff --git a/builtin/tag.c b/builtin/tag.c\n> index 9b6fd95..427d646 100644\n> --- a/builtin/tag.c\n> +++ b/builtin/tag.c\n> @@ -320,7 +320,7 @@ static int build_tag_object(struct strbuf *buf, int sign, unsigned char *result)\n>  }\n>  \n>  static void create_tag(const unsigned char *object, const char *tag,\n> -\t\t       struct strbuf *buf, int message, int sign,\n> +\t\t       struct strbuf *buf, int message, int sign, int nostrip,\n\nAgain, wrong naming convention. \"int strip\" would be fine but I think at\nthis point \"message, sign, strip\" tuple should become fields of \"struct\ncreate_tag_option\" that is passed to this funciton.\n\n>  \t\t       unsigned char *prev, unsigned char *result)\n>  {\n>  \tenum object_type type;\n> @@ -356,7 +356,7 @@ static void create_tag(const unsigned char *object, const char *tag,\n>  \n>  \t\tif (!is_null_sha1(prev))\n>  \t\t\twrite_tag_body(fd, prev);\n> -\t\telse\n> +\t\telse if (!nostrip)\n\nThis double negation comes only because the argument is misnamed with negation.\n"}]}