* [PATCH] tag: add --author option
@ 2012-03-27 16:00 Mathias Weber
2012-03-27 17:29 ` Zbigniew Jędrzejewski-Szmek
0 siblings, 1 reply; 7+ messages in thread
From: Mathias Weber @ 2012-03-27 16:00 UTC (permalink / raw)
To: git; +Cc: peff
The tag command does not support the --author option as the
commit command. This adds the --author option to create
annotated tags with a different author.
Signed-off-by: Mathias Weber <mathew.weber@gmail.com>
---
builtin/tag.c | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/builtin/tag.c b/builtin/tag.c
index fe7e5e5..416fa88 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -309,17 +309,34 @@ struct create_tag_options {
static void create_tag(const unsigned char *object, const char *tag,
struct strbuf *buf, struct create_tag_options *opt,
- unsigned char *prev, unsigned char *result)
+ unsigned char *prev, unsigned char *result,
+ const char *force_author)
{
enum object_type type;
char header_buf[1024];
int header_len;
char *path = NULL;
+ char *name, *email;
+ const char *author_ident;
type = sha1_object_info(object, NULL);
if (type <= OBJ_NONE)
die(_("bad object type."));
+ if (force_author) {
+ const char *lb = strstr(force_author, " <");
+ const char *rb = strchr(force_author, '>');
+
+ if (!lb || !rb)
+ die(_("malformed --author parameter"));
+ name = xstrndup(force_author, lb - force_author);
+ email = xstrndup(lb + 2, rb - (lb + 2));
+
+ author_ident = fmt_ident(name, email, getenv("GIT_AUTHOR_DATE"),
+ IDENT_ERROR_ON_NO_NAME);
+ } else
+ author_ident = git_committer_info(IDENT_ERROR_ON_NO_NAME);
+
header_len = snprintf(header_buf, sizeof(header_buf),
"object %s\n"
"type %s\n"
@@ -328,7 +345,7 @@ static void create_tag(const unsigned char *object, const char *tag,
sha1_to_hex(object),
typename(type),
tag,
- git_committer_info(IDENT_ERROR_ON_NO_NAME));
+ author_ident);
if (header_len > sizeof(header_buf) - 1)
die(_("tag header too big."));
@@ -438,6 +455,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
delete = 0, verify = 0;
const char *msgfile = NULL, *keyid = NULL;
struct msg_arg msg = { 0, STRBUF_INIT };
+ const char *force_author = NULL;
struct commit_list *with_commit = NULL;
struct option options[] = {
OPT_BOOLEAN('l', "list", &list, "list tag names"),
@@ -452,6 +470,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
"annotated tag, needs a message"),
OPT_CALLBACK('m', "message", &msg, "message",
"tag message", parse_msg_arg),
+ OPT_STRING(0, "author", &force_author, "author",
+ "override author for annotated tag"),
OPT_FILENAME('F', "file", &msgfile, "read message from file"),
OPT_BOOLEAN('s', "sign", &opt.sign, "annotated and GPG-signed tag"),
OPT_STRING(0, "cleanup", &cleanup_arg, "mode",
@@ -556,7 +576,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
die(_("Invalid cleanup mode %s"), cleanup_arg);
if (annotate)
- create_tag(object, tag, &buf, &opt, prev, object);
+ create_tag(object, tag, &buf, &opt, prev, object, force_author);
lock = lock_any_ref_for_update(ref.buf, prev, 0);
if (!lock)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] tag: add --author option
2012-03-27 16:00 [PATCH] tag: add --author option Mathias Weber
@ 2012-03-27 17:29 ` Zbigniew Jędrzejewski-Szmek
2012-03-27 20:32 ` Mathias Weber
2012-03-27 20:42 ` Junio C Hamano
0 siblings, 2 replies; 7+ messages in thread
From: Zbigniew Jędrzejewski-Szmek @ 2012-03-27 17:29 UTC (permalink / raw)
To: Mathias Weber; +Cc: git, peff
On 03/27/2012 06:00 PM, Mathias Weber wrote:
>
> The tag command does not support the --author option as the
> commit command. This adds the --author option to create
> annotated tags with a different author.
Consistency is good.
> Signed-off-by: Mathias Weber<mathew.weber@gmail.com>
> ---
> builtin/tag.c | 26 +++++++++++++++++++++++---
> 1 files changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/builtin/tag.c b/builtin/tag.c
> index fe7e5e5..416fa88 100644
> --- a/builtin/tag.c
> +++ b/builtin/tag.c
> @@ -309,17 +309,34 @@ struct create_tag_options {
>
> static void create_tag(const unsigned char *object, const char *tag,
> struct strbuf *buf, struct create_tag_options *opt,
> - unsigned char *prev, unsigned char *result)
> + unsigned char *prev, unsigned char *result,
> + const char *force_author)
> {
> enum object_type type;
> char header_buf[1024];
> int header_len;
> char *path = NULL;
> + char *name, *email;
> + const char *author_ident;
>
> type = sha1_object_info(object, NULL);
> if (type<= OBJ_NONE)
> die(_("bad object type."));
>
> + if (force_author) {
> + const char *lb = strstr(force_author, "<");
> + const char *rb = strchr(force_author, '>');
> +
> + if (!lb || !rb)
> + die(_("malformed --author parameter"));
> + name = xstrndup(force_author, lb - force_author);
> + email = xstrndup(lb + 2, rb - (lb + 2));
This part is identical to builtin/commit.c, it would be nice to refactor
it into a function.
Zbyszek
> +
> + author_ident = fmt_ident(name, email, getenv("GIT_AUTHOR_DATE"),
> + IDENT_ERROR_ON_NO_NAME);
> + } else
> + author_ident = git_committer_info(IDENT_ERROR_ON_NO_NAME);
> +
> header_len = snprintf(header_buf, sizeof(header_buf),
> "object %s\n"
> "type %s\n"
> @@ -328,7 +345,7 @@ static void create_tag(const unsigned char *object, const char *tag,
> sha1_to_hex(object),
> typename(type),
> tag,
> - git_committer_info(IDENT_ERROR_ON_NO_NAME));
> + author_ident);
>
> if (header_len> sizeof(header_buf) - 1)
> die(_("tag header too big."));
> @@ -438,6 +455,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
> delete = 0, verify = 0;
> const char *msgfile = NULL, *keyid = NULL;
> struct msg_arg msg = { 0, STRBUF_INIT };
> + const char *force_author = NULL;
> struct commit_list *with_commit = NULL;
> struct option options[] = {
> OPT_BOOLEAN('l', "list",&list, "list tag names"),
> @@ -452,6 +470,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
> "annotated tag, needs a message"),
> OPT_CALLBACK('m', "message",&msg, "message",
> "tag message", parse_msg_arg),
> + OPT_STRING(0, "author",&force_author, "author",
> + "override author for annotated tag"),
> OPT_FILENAME('F', "file",&msgfile, "read message from file"),
> OPT_BOOLEAN('s', "sign",&opt.sign, "annotated and GPG-signed tag"),
> OPT_STRING(0, "cleanup",&cleanup_arg, "mode",
> @@ -556,7 +576,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
> die(_("Invalid cleanup mode %s"), cleanup_arg);
>
> if (annotate)
> - create_tag(object, tag,&buf,&opt, prev, object);
> + create_tag(object, tag,&buf,&opt, prev, object, force_author);
>
> lock = lock_any_ref_for_update(ref.buf, prev, 0);
> if (!lock)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tag: add --author option
2012-03-27 17:29 ` Zbigniew Jędrzejewski-Szmek
@ 2012-03-27 20:32 ` Mathias Weber
2012-03-27 20:52 ` Junio C Hamano
2012-03-27 20:42 ` Junio C Hamano
1 sibling, 1 reply; 7+ messages in thread
From: Mathias Weber @ 2012-03-27 20:32 UTC (permalink / raw)
To: Zbigniew Jędrzejewski-Szmek; +Cc: git, peff
On 27.03.2012 19:29, Zbigniew Jędrzejewski-Szmek wrote:
> On 03/27/2012 06:00 PM, Mathias Weber wrote:
>>
>> The tag command does not support the --author option as the
>> commit command. This adds the --author option to create
>> annotated tags with a different author.
>
> Consistency is good.
It would be good but during the rework of the patch I realized that for
the tag the committer is and should be used and not the author.
Therefore it is fine that this option isn't available. I'm sorry
bothering you.
Thanks for your help.
Mathias
>
>> Signed-off-by: Mathias Weber<mathew.weber@gmail.com>
>> ---
>> builtin/tag.c | 26 +++++++++++++++++++++++---
>> 1 files changed, 23 insertions(+), 3 deletions(-)
>>
>> diff --git a/builtin/tag.c b/builtin/tag.c
>> index fe7e5e5..416fa88 100644
>> --- a/builtin/tag.c
>> +++ b/builtin/tag.c
>> @@ -309,17 +309,34 @@ struct create_tag_options {
>>
>> static void create_tag(const unsigned char *object, const char *tag,
>> struct strbuf *buf, struct create_tag_options *opt,
>> - unsigned char *prev, unsigned char *result)
>> + unsigned char *prev, unsigned char *result,
>> + const char *force_author)
>> {
>> enum object_type type;
>> char header_buf[1024];
>> int header_len;
>> char *path = NULL;
>> + char *name, *email;
>> + const char *author_ident;
>>
>> type = sha1_object_info(object, NULL);
>> if (type<= OBJ_NONE)
>> die(_("bad object type."));
>>
>> + if (force_author) {
>> + const char *lb = strstr(force_author, "<");
>> + const char *rb = strchr(force_author, '>');
>> +
>> + if (!lb || !rb)
>> + die(_("malformed --author parameter"));
>> + name = xstrndup(force_author, lb - force_author);
>> + email = xstrndup(lb + 2, rb - (lb + 2));
>
> This part is identical to builtin/commit.c, it would be nice to refactor
> it into a function.
>
> Zbyszek
>
>> +
>> + author_ident = fmt_ident(name, email, getenv("GIT_AUTHOR_DATE"),
>> + IDENT_ERROR_ON_NO_NAME);
>> + } else
>> + author_ident = git_committer_info(IDENT_ERROR_ON_NO_NAME);
>> +
>> header_len = snprintf(header_buf, sizeof(header_buf),
>> "object %s\n"
>> "type %s\n"
>> @@ -328,7 +345,7 @@ static void create_tag(const unsigned char
>> *object, const char *tag,
>> sha1_to_hex(object),
>> typename(type),
>> tag,
>> - git_committer_info(IDENT_ERROR_ON_NO_NAME));
>> + author_ident);
>>
>> if (header_len> sizeof(header_buf) - 1)
>> die(_("tag header too big."));
>> @@ -438,6 +455,7 @@ int cmd_tag(int argc, const char **argv, const
>> char *prefix)
>> delete = 0, verify = 0;
>> const char *msgfile = NULL, *keyid = NULL;
>> struct msg_arg msg = { 0, STRBUF_INIT };
>> + const char *force_author = NULL;
>> struct commit_list *with_commit = NULL;
>> struct option options[] = {
>> OPT_BOOLEAN('l', "list",&list, "list tag names"),
>> @@ -452,6 +470,8 @@ int cmd_tag(int argc, const char **argv, const
>> char *prefix)
>> "annotated tag, needs a message"),
>> OPT_CALLBACK('m', "message",&msg, "message",
>> "tag message", parse_msg_arg),
>> + OPT_STRING(0, "author",&force_author, "author",
>> + "override author for annotated tag"),
>> OPT_FILENAME('F', "file",&msgfile, "read message from file"),
>> OPT_BOOLEAN('s', "sign",&opt.sign, "annotated and GPG-signed
>> tag"),
>> OPT_STRING(0, "cleanup",&cleanup_arg, "mode",
>> @@ -556,7 +576,7 @@ int cmd_tag(int argc, const char **argv, const
>> char *prefix)
>> die(_("Invalid cleanup mode %s"), cleanup_arg);
>>
>> if (annotate)
>> - create_tag(object, tag,&buf,&opt, prev, object);
>> + create_tag(object, tag,&buf,&opt, prev, object, force_author);
>>
>> lock = lock_any_ref_for_update(ref.buf, prev, 0);
>> if (!lock)
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tag: add --author option
2012-03-27 20:32 ` Mathias Weber
@ 2012-03-27 20:52 ` Junio C Hamano
2012-03-27 21:11 ` Mathias Weber
0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2012-03-27 20:52 UTC (permalink / raw)
To: Mathias Weber; +Cc: Zbigniew Jędrzejewski-Szmek, git, peff
Mathias Weber <mweb@gmx.ch> writes:
> On 27.03.2012 19:29, Zbigniew Jędrzejewski-Szmek wrote:
>> On 03/27/2012 06:00 PM, Mathias Weber wrote:
>>>
>>> The tag command does not support the --author option as the
>>> commit command. This adds the --author option to create
>>> annotated tags with a different author.
>>
>> Consistency is good.
>
> It would be good but during the rework of the patch I realized that for
> the tag the committer is and should be used and not the author.
> Therefore it is fine that this option isn't available. I'm sorry
> bothering you.
I would have thought that being able to lie about "tagger " would be
equivalent to lying about --author of the commit. What am I missing?
Not that I am enthused by the idea of having to add another option. I
would be perfectly happy if we did not add such a flag. It is just I do
not understand the reasoning behind the retraction.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tag: add --author option
2012-03-27 20:52 ` Junio C Hamano
@ 2012-03-27 21:11 ` Mathias Weber
2012-03-27 23:05 ` Junio C Hamano
0 siblings, 1 reply; 7+ messages in thread
From: Mathias Weber @ 2012-03-27 21:11 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Zbigniew Jędrzejewski-Szmek, git, peff
On 27.03.2012 22:52, Junio C Hamano wrote:
> Mathias Weber <mweb@gmx.ch> writes:
>
>> On 27.03.2012 19:29, Zbigniew Jędrzejewski-Szmek wrote:
>>> On 03/27/2012 06:00 PM, Mathias Weber wrote:
>>>>
>>>> The tag command does not support the --author option as the
>>>> commit command. This adds the --author option to create
>>>> annotated tags with a different author.
>>>
>>> Consistency is good.
>>
>> It would be good but during the rework of the patch I realized that for
>> the tag the committer is and should be used and not the author.
>> Therefore it is fine that this option isn't available. I'm sorry
>> bothering you.
>
> I would have thought that being able to lie about "tagger " would be
> equivalent to lying about --author of the commit. What am I missing?
>
> Not that I am enthused by the idea of having to add another option. I
> would be perfectly happy if we did not add such a flag. It is just I do
> not understand the reasoning behind the retraction.
>
Yes this was what I first though as well but isn't the tagger similar to
the committer? With the --author option we change only the author of a
commit and not the committer. To change the committer you have to
provide the env variable GIT_COMMITTER_NAME and GIT_COMMITER_EMAIL or
change the config file. I haven't found a option to change the
committer. I think the tagger is about the same as the committer. It
make sens to have a committer and an author for a commit and this might
not even be the same person but for a tag there is only the tagger.
Which is the person how makes the tag.
Mathias
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tag: add --author option
2012-03-27 21:11 ` Mathias Weber
@ 2012-03-27 23:05 ` Junio C Hamano
0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2012-03-27 23:05 UTC (permalink / raw)
To: Mathias Weber; +Cc: Zbigniew Jędrzejewski-Szmek, git, peff
Mathias Weber <mweb@gmx.ch> writes:
> ... To change the committer you have to
> provide the env variable GIT_COMMITTER_NAME and GIT_COMMITER_EMAIL or
> change the config file. I haven't found a option to change the
> committer. I think the tagger is about the same as the committer.
OK, so not giving an easy option to forge it, while leaving the door open
for scripts to use GIT_COMMITTER_{NAME,EMAIL} to override it if needed, is
a good way to keep people honest and make the behaviour consistent across
tools. I can understand the reasoning.
Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] tag: add --author option
2012-03-27 17:29 ` Zbigniew Jędrzejewski-Szmek
2012-03-27 20:32 ` Mathias Weber
@ 2012-03-27 20:42 ` Junio C Hamano
1 sibling, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2012-03-27 20:42 UTC (permalink / raw)
To: Zbigniew Jędrzejewski-Szmek; +Cc: Mathias Weber, git, peff
Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> writes:
>> + if (force_author) {
>> + const char *lb = strstr(force_author, "<");
>> + const char *rb = strchr(force_author, '>');
>> +
>> + if (!lb || !rb)
>> + die(_("malformed --author parameter"));
>> + name = xstrndup(force_author, lb - force_author);
>> + email = xstrndup(lb + 2, rb - (lb + 2));
>
> This part is identical to builtin/commit.c, it would be nice to
> refactor it into a function.
Or we may want to use something like split_ident_line() from 4b340cf
(ident.c: add split_ident_line() to parse formatted ident line,
2012-03-11) to consolidate the parsing of this kind of stuff even further.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-03-27 23:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-27 16:00 [PATCH] tag: add --author option Mathias Weber
2012-03-27 17:29 ` Zbigniew Jędrzejewski-Szmek
2012-03-27 20:32 ` Mathias Weber
2012-03-27 20:52 ` Junio C Hamano
2012-03-27 21:11 ` Mathias Weber
2012-03-27 23:05 ` Junio C Hamano
2012-03-27 20:42 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).