{"thread":{"id":"30074","subject":"[PATCH] tag: add --author option","startedAt":"2012-03-27T16:00:21Z","lastAt":"2012-03-27T23:05:54Z","messageCount":7,"participants":["Mathias Weber","Zbigniew Jędrzejewski-Szmek","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"187862","messageId":"4F71E415.9030800@gmx.ch","threadId":"30074","inReplyTo":null,"subject":"[PATCH] tag: add --author option","fromName":"Mathias Weber","fromEmail":"mweb@gmx.ch","sentAt":"2012-03-27T16:00:21Z","receivedAt":"2012-03-27T16:00:21Z","isPatch":true,"sender":{"key":"mweb@gmx.ch","avatar":"https://gravatar.com/avatar/1fd6899e210089f4b166243f13b13afcbb2c55ef2e421846677b631b94d2ee41?d=mp&s=160"},"body":"\nThe tag command does not support the --author option as the\ncommit command. This adds the --author option to create\nannotated tags with a different author.\n\nSigned-off-by: Mathias Weber <mathew.weber@gmail.com>\n---\n builtin/tag.c |   26 +++++++++++++++++++++++---\n 1 files changed, 23 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex fe7e5e5..416fa88 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -309,17 +309,34 @@ struct create_tag_options {\n \n static void create_tag(const unsigned char *object, const char *tag,\n \t\t       struct strbuf *buf, struct create_tag_options *opt,\n-\t\t       unsigned char *prev, unsigned char *result)\n+\t\t       unsigned char *prev, unsigned char *result,\n+\t\t       const char *force_author)\n {\n \tenum object_type type;\n \tchar header_buf[1024];\n \tint header_len;\n \tchar *path = NULL;\n+\tchar *name, *email;\n+\tconst char *author_ident;\n \n \ttype = sha1_object_info(object, NULL);\n \tif (type <= OBJ_NONE)\n \t    die(_(\"bad object type.\"));\n \n+\tif (force_author) {\n+\t\tconst char *lb = strstr(force_author, \" <\");\n+\t\tconst char *rb = strchr(force_author, '>');\n+\n+\t\tif (!lb || !rb)\n+\t\t\tdie(_(\"malformed --author parameter\"));\n+\t\t\tname = xstrndup(force_author, lb - force_author);\n+\t\t\temail = xstrndup(lb + 2, rb - (lb + 2));\n+\n+\t\tauthor_ident = fmt_ident(name, email, getenv(\"GIT_AUTHOR_DATE\"),\n+\t\t\t\tIDENT_ERROR_ON_NO_NAME);\n+\t} else\n+\t\tauthor_ident = git_committer_info(IDENT_ERROR_ON_NO_NAME);\n+\n \theader_len = snprintf(header_buf, sizeof(header_buf),\n \t\t\t  \"object %s\\n\"\n \t\t\t  \"type %s\\n\"\n@@ -328,7 +345,7 @@ static void create_tag(const unsigned char *object, const char *tag,\n \t\t\t  sha1_to_hex(object),\n \t\t\t  typename(type),\n \t\t\t  tag,\n-\t\t\t  git_committer_info(IDENT_ERROR_ON_NO_NAME));\n+\t\t\t  author_ident);\n \n \tif (header_len > sizeof(header_buf) - 1)\n \t\tdie(_(\"tag header too big.\"));\n@@ -438,6 +455,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\tdelete = 0, verify = 0;\n \tconst char *msgfile = NULL, *keyid = NULL;\n \tstruct msg_arg msg = { 0, STRBUF_INIT };\n+\tconst char *force_author = NULL;\n \tstruct commit_list *with_commit = NULL;\n \tstruct option options[] = {\n \t\tOPT_BOOLEAN('l', \"list\", &list, \"list tag names\"),\n@@ -452,6 +470,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\t\t\t\t\"annotated tag, needs a message\"),\n \t\tOPT_CALLBACK('m', \"message\", &msg, \"message\",\n \t\t\t     \"tag message\", parse_msg_arg),\n+\t\tOPT_STRING(0, \"author\", &force_author, \"author\",\n+\t\t\t\t \"override author for annotated tag\"),\n \t\tOPT_FILENAME('F', \"file\", &msgfile, \"read message from file\"),\n \t\tOPT_BOOLEAN('s', \"sign\", &opt.sign, \"annotated and GPG-signed tag\"),\n \t\tOPT_STRING(0, \"cleanup\", &cleanup_arg, \"mode\",\n@@ -556,7 +576,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\tdie(_(\"Invalid cleanup mode %s\"), cleanup_arg);\n \n \tif (annotate)\n-\t\tcreate_tag(object, tag, &buf, &opt, prev, object);\n+\t\tcreate_tag(object, tag, &buf, &opt, prev, object, force_author);\n \n \tlock = lock_any_ref_for_update(ref.buf, prev, 0);\n \tif (!lock)\n-- \n1.7.5.4\n"},{"id":"187868","messageId":"4F71F902.8090200@in.waw.pl","threadId":"30074","inReplyTo":"4F71E415.9030800@gmx.ch","subject":"Re: [PATCH] tag: add --author option","fromName":"Zbigniew Jędrzejewski-Szmek","fromEmail":"zbyszek@in.waw.pl","sentAt":"2012-03-27T17:29:38Z","receivedAt":"2012-03-27T17:29:38Z","isPatch":true,"sender":{"key":"zbyszek@in.waw.pl","avatar":"https://avatars.githubusercontent.com/u/349618?v=4"},"body":"On 03/27/2012 06:00 PM, Mathias Weber wrote:\n>\n> The tag command does not support the --author option as the\n> commit command. This adds the --author option to create\n> annotated tags with a different author.\n\nConsistency is good.\n\n> Signed-off-by: Mathias Weber<mathew.weber@gmail.com>\n> ---\n>   builtin/tag.c |   26 +++++++++++++++++++++++---\n>   1 files changed, 23 insertions(+), 3 deletions(-)\n>\n> diff --git a/builtin/tag.c b/builtin/tag.c\n> index fe7e5e5..416fa88 100644\n> --- a/builtin/tag.c\n> +++ b/builtin/tag.c\n> @@ -309,17 +309,34 @@ struct create_tag_options {\n>\n>   static void create_tag(const unsigned char *object, const char *tag,\n>   \t\t       struct strbuf *buf, struct create_tag_options *opt,\n> -\t\t       unsigned char *prev, unsigned char *result)\n> +\t\t       unsigned char *prev, unsigned char *result,\n> +\t\t       const char *force_author)\n>   {\n>   \tenum object_type type;\n>   \tchar header_buf[1024];\n>   \tint header_len;\n>   \tchar *path = NULL;\n> +\tchar *name, *email;\n> +\tconst char *author_ident;\n>\n>   \ttype = sha1_object_info(object, NULL);\n>   \tif (type<= OBJ_NONE)\n>   \t    die(_(\"bad object type.\"));\n>\n> +\tif (force_author) {\n> +\t\tconst char *lb = strstr(force_author, \"<\");\n> +\t\tconst char *rb = strchr(force_author, '>');\n> +\n> +\t\tif (!lb || !rb)\n> +\t\t\tdie(_(\"malformed --author parameter\"));\n> +\t\t\tname = xstrndup(force_author, lb - force_author);\n> +\t\t\temail = xstrndup(lb + 2, rb - (lb + 2));\n\nThis part is identical to builtin/commit.c, it would be nice to refactor \nit into a function.\n\nZbyszek\n\n> +\n> +\t\tauthor_ident = fmt_ident(name, email, getenv(\"GIT_AUTHOR_DATE\"),\n> +\t\t\t\tIDENT_ERROR_ON_NO_NAME);\n> +\t} else\n> +\t\tauthor_ident = git_committer_info(IDENT_ERROR_ON_NO_NAME);\n> +\n>   \theader_len = snprintf(header_buf, sizeof(header_buf),\n>   \t\t\t  \"object %s\\n\"\n>   \t\t\t  \"type %s\\n\"\n> @@ -328,7 +345,7 @@ static void create_tag(const unsigned char *object, const char *tag,\n>   \t\t\t  sha1_to_hex(object),\n>   \t\t\t  typename(type),\n>   \t\t\t  tag,\n> -\t\t\t  git_committer_info(IDENT_ERROR_ON_NO_NAME));\n> +\t\t\t  author_ident);\n>\n>   \tif (header_len>  sizeof(header_buf) - 1)\n>   \t\tdie(_(\"tag header too big.\"));\n> @@ -438,6 +455,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n>   \t\tdelete = 0, verify = 0;\n>   \tconst char *msgfile = NULL, *keyid = NULL;\n>   \tstruct msg_arg msg = { 0, STRBUF_INIT };\n> +\tconst char *force_author = NULL;\n>   \tstruct commit_list *with_commit = NULL;\n>   \tstruct option options[] = {\n>   \t\tOPT_BOOLEAN('l', \"list\",&list, \"list tag names\"),\n> @@ -452,6 +470,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n>   \t\t\t\t\t\"annotated tag, needs a message\"),\n>   \t\tOPT_CALLBACK('m', \"message\",&msg, \"message\",\n>   \t\t\t     \"tag message\", parse_msg_arg),\n> +\t\tOPT_STRING(0, \"author\",&force_author, \"author\",\n> +\t\t\t\t \"override author for annotated tag\"),\n>   \t\tOPT_FILENAME('F', \"file\",&msgfile, \"read message from file\"),\n>   \t\tOPT_BOOLEAN('s', \"sign\",&opt.sign, \"annotated and GPG-signed tag\"),\n>   \t\tOPT_STRING(0, \"cleanup\",&cleanup_arg, \"mode\",\n> @@ -556,7 +576,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n>   \t\tdie(_(\"Invalid cleanup mode %s\"), cleanup_arg);\n>\n>   \tif (annotate)\n> -\t\tcreate_tag(object, tag,&buf,&opt, prev, object);\n> +\t\tcreate_tag(object, tag,&buf,&opt, prev, object, force_author);\n>\n>   \tlock = lock_any_ref_for_update(ref.buf, prev, 0);\n>   \tif (!lock)\n"},{"id":"187891","messageId":"4F7223D0.5000801@gmx.ch","threadId":"30074","inReplyTo":"4F71F902.8090200@in.waw.pl","subject":"Re: [PATCH] tag: add --author option","fromName":"Mathias Weber","fromEmail":"mweb@gmx.ch","sentAt":"2012-03-27T20:32:16Z","receivedAt":"2012-03-27T20:32:16Z","isPatch":true,"sender":{"key":"mweb@gmx.ch","avatar":"https://gravatar.com/avatar/1fd6899e210089f4b166243f13b13afcbb2c55ef2e421846677b631b94d2ee41?d=mp&s=160"},"body":"On 27.03.2012 19:29, Zbigniew Jędrzejewski-Szmek wrote:\n> On 03/27/2012 06:00 PM, Mathias Weber wrote:\n>>\n>> The tag command does not support the --author option as the\n>> commit command. This adds the --author option to create\n>> annotated tags with a different author.\n> \n> Consistency is good.\n\nIt would be good but during the rework of the patch I realized that for\nthe tag the committer is and should be used and not the author.\nTherefore it is fine that this option isn't available. I'm sorry\nbothering you.\n\nThanks for your help.\n\nMathias\n\n> \n>> Signed-off-by: Mathias Weber<mathew.weber@gmail.com>\n>> ---\n>>   builtin/tag.c |   26 +++++++++++++++++++++++---\n>>   1 files changed, 23 insertions(+), 3 deletions(-)\n>>\n>> diff --git a/builtin/tag.c b/builtin/tag.c\n>> index fe7e5e5..416fa88 100644\n>> --- a/builtin/tag.c\n>> +++ b/builtin/tag.c\n>> @@ -309,17 +309,34 @@ struct create_tag_options {\n>>\n>>   static void create_tag(const unsigned char *object, const char *tag,\n>>                  struct strbuf *buf, struct create_tag_options *opt,\n>> -               unsigned char *prev, unsigned char *result)\n>> +               unsigned char *prev, unsigned char *result,\n>> +               const char *force_author)\n>>   {\n>>       enum object_type type;\n>>       char header_buf[1024];\n>>       int header_len;\n>>       char *path = NULL;\n>> +    char *name, *email;\n>> +    const char *author_ident;\n>>\n>>       type = sha1_object_info(object, NULL);\n>>       if (type<= OBJ_NONE)\n>>           die(_(\"bad object type.\"));\n>>\n>> +    if (force_author) {\n>> +        const char *lb = strstr(force_author, \"<\");\n>> +        const char *rb = strchr(force_author, '>');\n>> +\n>> +        if (!lb || !rb)\n>> +            die(_(\"malformed --author parameter\"));\n>> +            name = xstrndup(force_author, lb - force_author);\n>> +            email = xstrndup(lb + 2, rb - (lb + 2));\n> \n> This part is identical to builtin/commit.c, it would be nice to refactor\n> it into a function.\n> \n> Zbyszek\n> \n>> +\n>> +        author_ident = fmt_ident(name, email, getenv(\"GIT_AUTHOR_DATE\"),\n>> +                IDENT_ERROR_ON_NO_NAME);\n>> +    } else\n>> +        author_ident = git_committer_info(IDENT_ERROR_ON_NO_NAME);\n>> +\n>>       header_len = snprintf(header_buf, sizeof(header_buf),\n>>                 \"object %s\\n\"\n>>                 \"type %s\\n\"\n>> @@ -328,7 +345,7 @@ static void create_tag(const unsigned char\n>> *object, const char *tag,\n>>                 sha1_to_hex(object),\n>>                 typename(type),\n>>                 tag,\n>> -              git_committer_info(IDENT_ERROR_ON_NO_NAME));\n>> +              author_ident);\n>>\n>>       if (header_len>  sizeof(header_buf) - 1)\n>>           die(_(\"tag header too big.\"));\n>> @@ -438,6 +455,7 @@ int cmd_tag(int argc, const char **argv, const\n>> char *prefix)\n>>           delete = 0, verify = 0;\n>>       const char *msgfile = NULL, *keyid = NULL;\n>>       struct msg_arg msg = { 0, STRBUF_INIT };\n>> +    const char *force_author = NULL;\n>>       struct commit_list *with_commit = NULL;\n>>       struct option options[] = {\n>>           OPT_BOOLEAN('l', \"list\",&list, \"list tag names\"),\n>> @@ -452,6 +470,8 @@ int cmd_tag(int argc, const char **argv, const\n>> char *prefix)\n>>                       \"annotated tag, needs a message\"),\n>>           OPT_CALLBACK('m', \"message\",&msg, \"message\",\n>>                    \"tag message\", parse_msg_arg),\n>> +        OPT_STRING(0, \"author\",&force_author, \"author\",\n>> +                 \"override author for annotated tag\"),\n>>           OPT_FILENAME('F', \"file\",&msgfile, \"read message from file\"),\n>>           OPT_BOOLEAN('s', \"sign\",&opt.sign, \"annotated and GPG-signed\n>> tag\"),\n>>           OPT_STRING(0, \"cleanup\",&cleanup_arg, \"mode\",\n>> @@ -556,7 +576,7 @@ int cmd_tag(int argc, const char **argv, const\n>> char *prefix)\n>>           die(_(\"Invalid cleanup mode %s\"), cleanup_arg);\n>>\n>>       if (annotate)\n>> -        create_tag(object, tag,&buf,&opt, prev, object);\n>> +        create_tag(object, tag,&buf,&opt, prev, object, force_author);\n>>\n>>       lock = lock_any_ref_for_update(ref.buf, prev, 0);\n>>       if (!lock)\n> \n> \n"},{"id":"187893","messageId":"7vvclphj2x.fsf@alter.siamese.dyndns.org","threadId":"30074","inReplyTo":"4F71F902.8090200@in.waw.pl","subject":"Re: [PATCH] tag: add --author option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-27T20:42:14Z","receivedAt":"2012-03-27T20:42:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Zbigniew Jędrzejewski-Szmek  <zbyszek@in.waw.pl> writes:\n\n>> +\tif (force_author) {\n>> +\t\tconst char *lb = strstr(force_author, \"<\");\n>> +\t\tconst char *rb = strchr(force_author, '>');\n>> +\n>> +\t\tif (!lb || !rb)\n>> +\t\t\tdie(_(\"malformed --author parameter\"));\n>> +\t\t\tname = xstrndup(force_author, lb - force_author);\n>> +\t\t\temail = xstrndup(lb + 2, rb - (lb + 2));\n>\n> This part is identical to builtin/commit.c, it would be nice to\n> refactor it into a function.\n\nOr we may want to use something like split_ident_line() from 4b340cf\n(ident.c: add split_ident_line() to parse formatted ident line,\n2012-03-11) to consolidate the parsing of this kind of stuff even further.\n"},{"id":"187894","messageId":"7vr4wdhilj.fsf@alter.siamese.dyndns.org","threadId":"30074","inReplyTo":"4F7223D0.5000801@gmx.ch","subject":"Re: [PATCH] tag: add --author option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-27T20:52:40Z","receivedAt":"2012-03-27T20:52:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mathias Weber <mweb@gmx.ch> writes:\n\n> On 27.03.2012 19:29, Zbigniew Jędrzejewski-Szmek wrote:\n>> On 03/27/2012 06:00 PM, Mathias Weber wrote:\n>>>\n>>> The tag command does not support the --author option as the\n>>> commit command. This adds the --author option to create\n>>> annotated tags with a different author.\n>> \n>> Consistency is good.\n>\n> It would be good but during the rework of the patch I realized that for\n> the tag the committer is and should be used and not the author.\n> Therefore it is fine that this option isn't available. I'm sorry\n> bothering you.\n\nI would have thought that being able to lie about \"tagger \" would be\nequivalent to lying about --author of the commit.  What am I missing?\n\nNot that I am enthused by the idea of having to add another option.  I\nwould be perfectly happy if we did not add such a flag.  It is just I do\nnot understand the reasoning behind the retraction.\n"},{"id":"187895","messageId":"4F722D18.50502@gmx.ch","threadId":"30074","inReplyTo":"7vr4wdhilj.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] tag: add --author option","fromName":"Mathias Weber","fromEmail":"mweb@gmx.ch","sentAt":"2012-03-27T21:11:52Z","receivedAt":"2012-03-27T21:11:52Z","isPatch":true,"sender":{"key":"mweb@gmx.ch","avatar":"https://gravatar.com/avatar/1fd6899e210089f4b166243f13b13afcbb2c55ef2e421846677b631b94d2ee41?d=mp&s=160"},"body":"On 27.03.2012 22:52, Junio C Hamano wrote:\n> Mathias Weber <mweb@gmx.ch> writes:\n> \n>> On 27.03.2012 19:29, Zbigniew Jędrzejewski-Szmek wrote:\n>>> On 03/27/2012 06:00 PM, Mathias Weber wrote:\n>>>>\n>>>> The tag command does not support the --author option as the\n>>>> commit command. This adds the --author option to create\n>>>> annotated tags with a different author.\n>>>\n>>> Consistency is good.\n>>\n>> It would be good but during the rework of the patch I realized that for\n>> the tag the committer is and should be used and not the author.\n>> Therefore it is fine that this option isn't available. I'm sorry\n>> bothering you.\n> \n> I would have thought that being able to lie about \"tagger \" would be\n> equivalent to lying about --author of the commit.  What am I missing?\n> \n> Not that I am enthused by the idea of having to add another option.  I\n> would be perfectly happy if we did not add such a flag.  It is just I do\n> not understand the reasoning behind the retraction.\n> \n\nYes this was what I first though as well but isn't the tagger similar to\nthe committer? With the --author option we change only the author of a\ncommit and not the committer. To change the committer you have to\nprovide the env variable GIT_COMMITTER_NAME and GIT_COMMITER_EMAIL or\nchange the config file. I haven't found a option to change the\ncommitter. I think the tagger is about the same as the committer. It\nmake sens to have a committer and an author for a commit and this might\nnot even be the same person but for a tag there is only the tagger.\nWhich is the person how makes the tag.\n\nMathias\n"},{"id":"187900","messageId":"7v1uodzlt9.fsf@alter.siamese.dyndns.org","threadId":"30074","inReplyTo":"4F722D18.50502@gmx.ch","subject":"Re: [PATCH] tag: add --author option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-27T23:05:54Z","receivedAt":"2012-03-27T23:05:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mathias Weber <mweb@gmx.ch> writes:\n\n> ... To change the committer you have to\n> provide the env variable GIT_COMMITTER_NAME and GIT_COMMITER_EMAIL or\n> change the config file. I haven't found a option to change the\n> committer. I think the tagger is about the same as the committer.\n\nOK, so not giving an easy option to forge it, while leaving the door open\nfor scripts to use GIT_COMMITTER_{NAME,EMAIL} to override it if needed, is\na good way to keep people honest and make the behaviour consistent across\ntools.  I can understand the reasoning.\n\nThanks.\n"}]}