{"thread":{"id":"32317","subject":"[PATCH 0/5] Allow git log to use mailmap file","startedAt":"2012-12-11T22:21:28Z","lastAt":"2012-12-12T17:58:38Z","messageCount":12,"participants":["Antoine Pelisse","Junio C Hamano","Rich Midwinter"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"204692","messageId":"1355264493-8298-1-git-send-email-apelisse@gmail.com","threadId":"32317","inReplyTo":null,"subject":"[PATCH 0/5] Allow git log to use mailmap file","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2012-12-11T22:21:28Z","receivedAt":"2012-12-11T22:21:28Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"Implement the feature suggested here [1] by Rich Mindwinter\nand Junio C Hamano (and following his advices)\n\nThis is a pre-version so there are a bunch of things still missing,\namong them:\n - There is no tests\n - Grep search for mailmap author/committer is not available\n - There is no documentation of the new option\n\n[1]: http://thread.gmane.org/gmane.comp.version-control.git/211270\n\nAntoine Pelisse (5):\n  Use split_ident_line to parse author and committer\n  mailmap: Remove buffer length limit in map_user\n  mailmap: Add mailmap structure to rev_info and pp\n  pretty: Use mailmap to display username and email\n  log: Add --use-mailmap option\n\n builtin/blame.c | 59 +++++++++++++++++-------------------------------\n builtin/log.c   |  9 +++++++-\n commit.h        |  1 +\n log-tree.c      |  1 +\n mailmap.c       | 16 ++++++-------\n pretty.c        | 70 ++++++++++++++++++++++++++++++++++++---------------------\n revision.h      |  1 +\n 7 files changed, 84 insertions(+), 73 deletions(-)\n\n--\n1.8.1.rc1.5.g7e0651a\n"},{"id":"204695","messageId":"1355264493-8298-2-git-send-email-apelisse@gmail.com","threadId":"32317","inReplyTo":"1355264493-8298-1-git-send-email-apelisse@gmail.com","subject":"[PATCH 1/5] Use split_ident_line to parse author and committer","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2012-12-11T22:21:29Z","receivedAt":"2012-12-11T22:21:29Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"Currently blame.c::get_acline and pretty.c::pp_user_info()\nare parsing author name, email, time and tz themselves.\n\nUse ident.c::split_ident_line for better code reuse.\n\nSigned-off-by: Antoine Pelisse <apelisse@gmail.com>\n---\n builtin/blame.c | 59 ++++++++++++++++++++-------------------------------------\n pretty.c        | 32 +++++++++++++++++--------------\n 2 files changed, 39 insertions(+), 52 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex cfae569..dd4aff9 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -1343,8 +1343,9 @@ static void get_ac_line(const char *inbuf, const char *what,\n \t\t\tint mail_len, char *mail,\n \t\t\tunsigned long *time, const char **tz)\n {\n-\tint len, tzlen, maillen;\n-\tchar *tmp, *endp, *timepos, *mailpos;\n+\tstruct ident_split ident;\n+\tint len, tzlen, maillen, namelen;\n+\tchar *tmp, *endp, *mailpos;\n \n \ttmp = strstr(inbuf, what);\n \tif (!tmp)\n@@ -1355,7 +1356,10 @@ static void get_ac_line(const char *inbuf, const char *what,\n \t\tlen = strlen(tmp);\n \telse\n \t\tlen = endp - tmp;\n-\tif (person_len <= len) {\n+\tif (person_len <= len)\n+\t\tgoto error_out;\n+\n+\tif (split_ident_line(&ident, tmp, len)) {\n \terror_out:\n \t\t/* Ugh */\n \t\t*tz = \"(unknown)\";\n@@ -1364,47 +1368,26 @@ static void get_ac_line(const char *inbuf, const char *what,\n \t\t*time = 0;\n \t\treturn;\n \t}\n-\tmemcpy(person, tmp, len);\n \n-\ttmp = person;\n-\ttmp += len;\n-\t*tmp = 0;\n-\twhile (person < tmp && *tmp != ' ')\n-\t\ttmp--;\n-\tif (tmp <= person)\n-\t\tgoto error_out;\n-\t*tz = tmp+1;\n-\ttzlen = (person+len)-(tmp+1);\n+\tnamelen = ident.name_end - ident.name_begin;\n+\tmemcpy(person, ident.name_begin, namelen);\n+\tperson[namelen] = 0;\n \n-\t*tmp = 0;\n-\twhile (person < tmp && *tmp != ' ')\n-\t\ttmp--;\n-\tif (tmp <= person)\n-\t\tgoto error_out;\n-\t*time = strtoul(tmp, NULL, 10);\n-\ttimepos = tmp;\n+\tmaillen = ident.mail_end - ident.mail_begin + 2;\n+\tmemcpy(mail, ident.mail_begin - 1, maillen);\n+\tmail[maillen] = 0;\n \n-\t*tmp = 0;\n-\twhile (person < tmp && !(*tmp == ' ' && tmp[1] == '<'))\n-\t\ttmp--;\n-\tif (tmp <= person)\n-\t\treturn;\n-\tmailpos = tmp + 1;\n-\t*tmp = 0;\n-\tmaillen = timepos - tmp;\n-\tmemcpy(mail, mailpos, maillen);\n+\t*time = strtoul(ident.date_begin, NULL, 10);\n \n-\tif (!mailmap.nr)\n-\t\treturn;\n+\ttzlen = ident.tz_end - ident.tz_begin;\n \n-\t/*\n-\t * mailmap expansion may make the name longer.\n-\t * make room by pushing stuff down.\n-\t */\n-\ttmp = person + person_len - (tzlen + 1);\n-\tmemmove(tmp, *tz, tzlen);\n+\t/* Place tz at the end of person */\n+\t*tz = tmp = person + person_len - (tzlen + 1);\n+\tmemcpy(tmp, ident.tz_begin, tzlen);\n \ttmp[tzlen] = 0;\n-\t*tz = tmp;\n+\n+\tif (!mailmap.nr)\n+\t\treturn;\n \n \t/*\n \t * Now, convert both name and e-mail using mailmap\ndiff --git a/pretty.c b/pretty.c\nindex 5bdc2e7..6730add 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -387,29 +387,33 @@ void pp_user_info(const struct pretty_print_context *pp,\n \t\t  const char *what, struct strbuf *sb,\n \t\t  const char *line, const char *encoding)\n {\n+\tstruct ident_split ident;\n+\tint linelen, namelen;\n+\tchar *line_end, *date;\n \tint max_length = 78; /* per rfc2822 */\n-\tchar *date;\n-\tint namelen;\n \tunsigned long time;\n \tint tz;\n \n \tif (pp->fmt == CMIT_FMT_ONELINE)\n \t\treturn;\n-\tdate = strchr(line, '>');\n-\tif (!date)\n+\n+\tline_end = strchr(line, '\\n');\n+\tif (!line_end)\n+\t\treturn;\n+\n+\tlinelen = ++line_end - line;\n+\tif (split_ident_line(&ident, line, linelen))\n \t\treturn;\n-\tnamelen = ++date - line;\n-\ttime = strtoul(date, &date, 10);\n+\n+\tnamelen = ident.mail_end - ident.name_begin + 1;\n+\ttime = strtoul(ident.date_begin, &date, 10);\n \ttz = strtol(date, NULL, 10);\n \n \tif (pp->fmt == CMIT_FMT_EMAIL) {\n-\t\tchar *name_tail = strchr(line, '<');\n \t\tint display_name_length;\n-\t\tif (!name_tail)\n-\t\t\treturn;\n-\t\twhile (line < name_tail && isspace(name_tail[-1]))\n-\t\t\tname_tail--;\n-\t\tdisplay_name_length = name_tail - line;\n+\n+\t\tdisplay_name_length = ident.name_end - ident.name_begin;\n+\n \t\tstrbuf_addstr(sb, \"From: \");\n \t\tif (needs_rfc2047_encoding(line, display_name_length, RFC2047_ADDRESS)) {\n \t\t\tadd_rfc2047(sb, line, display_name_length,\n@@ -427,10 +431,10 @@ void pp_user_info(const struct pretty_print_context *pp,\n \t\t}\n \t\tif (namelen - display_name_length + last_line_length(sb) > max_length) {\n \t\t\tstrbuf_addch(sb, '\\n');\n-\t\t\tif (!isspace(name_tail[0]))\n+\t\t\tif (!isspace(ident.name_end[0]))\n \t\t\t\tstrbuf_addch(sb, ' ');\n \t\t}\n-\t\tstrbuf_add(sb, name_tail, namelen - display_name_length);\n+\t\tstrbuf_add(sb, ident.name_end, namelen - display_name_length);\n \t\tstrbuf_addch(sb, '\\n');\n \t} else {\n \t\tstrbuf_addf(sb, \"%s: %.*s%.*s\\n\", what,\n-- \n1.8.1.rc1.5.g7e0651a\n"},{"id":"204693","messageId":"1355264493-8298-3-git-send-email-apelisse@gmail.com","threadId":"32317","inReplyTo":"1355264493-8298-1-git-send-email-apelisse@gmail.com","subject":"[PATCH 2/5] mailmap: Remove buffer length limit in map_user","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2012-12-11T22:21:30Z","receivedAt":"2012-12-11T22:21:30Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"Remove the hard limit set by mail buffer in map_user and\nuse the strbuf API to replace it.\n\nSigned-off-by: Antoine Pelisse <apelisse@gmail.com>\n---\n mailmap.c | 16 +++++++---------\n 1 file changed, 7 insertions(+), 9 deletions(-)\n\ndiff --git a/mailmap.c b/mailmap.c\nindex ea4b471..e636278 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -193,7 +193,8 @@ int map_user(struct string_list *map,\n \tchar *end_of_email;\n \tstruct string_list_item *item;\n \tstruct mailmap_entry *me;\n-\tchar buf[1024], *mailbuf;\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tchar *mailbuf;\n \tint i;\n \n \t/* figure out space requirement for email */\n@@ -204,15 +205,13 @@ int map_user(struct string_list *map,\n \t\tif (!end_of_email)\n \t\t\treturn 0;\n \t}\n-\tif (end_of_email - email + 1 < sizeof(buf))\n-\t\tmailbuf = buf;\n-\telse\n-\t\tmailbuf = xmalloc(end_of_email - email + 1);\n \n \t/* downcase the email address */\n+\tstrbuf_grow(&buf, end_of_email - email);\n \tfor (i = 0; i < end_of_email - email; i++)\n-\t\tmailbuf[i] = tolower(email[i]);\n-\tmailbuf[i] = 0;\n+\t\tstrbuf_addch(&buf, tolower(email[i]));\n+\tstrbuf_addch(&buf, 0);\n+\tmailbuf = strbuf_detach(&buf, 0);\n \n \tdebug_mm(\"map_user: map '%s' <%s>\\n\", name, mailbuf);\n \titem = string_list_lookup(map, mailbuf);\n@@ -226,8 +225,7 @@ int map_user(struct string_list *map,\n \t\t\t\titem = subitem;\n \t\t}\n \t}\n-\tif (mailbuf != buf)\n-\t\tfree(mailbuf);\n+\tfree(mailbuf);\n \tif (item != NULL) {\n \t\tstruct mailmap_info *mi = (struct mailmap_info *)item->util;\n \t\tif (mi->name == NULL && (mi->email == NULL || maxlen_email == 0)) {\n-- \n1.8.1.rc1.5.g7e0651a\n"},{"id":"204694","messageId":"1355264493-8298-4-git-send-email-apelisse@gmail.com","threadId":"32317","inReplyTo":"1355264493-8298-1-git-send-email-apelisse@gmail.com","subject":"[PATCH 3/5] mailmap: Add mailmap structure to rev_info and pp","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2012-12-11T22:21:31Z","receivedAt":"2012-12-11T22:21:31Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"the mailmap string_list structure filled with mailmap\ninformation is passed along from rev_info to pretty_print_context\nto provide mailmap information to pretty print each commits\nwith the correct username and email.\n\nSigned-off-by: Antoine Pelisse <apelisse@gmail.com>\n---\n commit.h   | 1 +\n log-tree.c | 1 +\n revision.h | 1 +\n 3 files changed, 3 insertions(+)\n\ndiff --git a/commit.h b/commit.h\nindex b6ad8f3..7f8f987 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -89,6 +89,7 @@ struct pretty_print_context {\n \tchar *notes_message;\n \tstruct reflog_walk_info *reflog_info;\n \tconst char *output_encoding;\n+\tstruct string_list *mailmap;\n };\n \n struct userformat_want {\ndiff --git a/log-tree.c b/log-tree.c\nindex 4f86def..92254fd 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -671,6 +671,7 @@ void show_log(struct rev_info *opt)\n \tctx.preserve_subject = opt->preserve_subject;\n \tctx.reflog_info = opt->reflog_info;\n \tctx.fmt = opt->commit_format;\n+\tctx.mailmap = opt->mailmap;\n \tpretty_print_commit(&ctx, commit, &msgbuf);\n \n \tif (opt->add_signoff)\ndiff --git a/revision.h b/revision.h\nindex 059bfff..83a79f5 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -143,6 +143,7 @@ struct rev_info {\n \tconst char\t*subject_prefix;\n \tint\t\tno_inline;\n \tint\t\tshow_log_size;\n+\tstruct string_list *mailmap;\n \n \t/* Filter by commit log message */\n \tstruct grep_opt\tgrep_filter;\n-- \n1.8.1.rc1.5.g7e0651a\n"},{"id":"204696","messageId":"1355264493-8298-5-git-send-email-apelisse@gmail.com","threadId":"32317","inReplyTo":"1355264493-8298-1-git-send-email-apelisse@gmail.com","subject":"[PATCH 4/5] pretty: Use mailmap to display username and email","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2012-12-11T22:21:32Z","receivedAt":"2012-12-11T22:21:32Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"Use the mailmap information to display the correct\nusername and email address in all log commands.\n\nSigned-off-by: Antoine Pelisse <apelisse@gmail.com>\n---\n pretty.c | 46 +++++++++++++++++++++++++++++++---------------\n 1 file changed, 31 insertions(+), 15 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex 6730add..e232aaa 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -387,6 +387,8 @@ void pp_user_info(const struct pretty_print_context *pp,\n \t\t  const char *what, struct strbuf *sb,\n \t\t  const char *line, const char *encoding)\n {\n+\tchar person_name[1024];\n+\tchar person_mail[1024];\n \tstruct ident_split ident;\n \tint linelen, namelen;\n \tchar *line_end, *date;\n@@ -405,41 +407,55 @@ void pp_user_info(const struct pretty_print_context *pp,\n \tif (split_ident_line(&ident, line, linelen))\n \t\treturn;\n \n-\tnamelen = ident.mail_end - ident.name_begin + 1;\n+\tmemcpy(person_mail, ident.mail_begin, ident.mail_end - ident.mail_begin);\n+\tperson_mail[ident.mail_end - ident.mail_begin] = 0;\n+\n+\tmemcpy(person_name, ident.name_begin, ident.name_end - ident.name_begin);\n+\tperson_name[ident.name_end - ident.name_begin] = 0;\n+\n+\tif (pp->mailmap)\n+\t\tmap_user(pp->mailmap, person_mail, sizeof(person_mail),\n+\t\t\t person_name, sizeof(person_name));\n+\n+\tnamelen = strlen(person_name) + strlen(person_mail);\n \ttime = strtoul(ident.date_begin, &date, 10);\n \ttz = strtol(date, NULL, 10);\n \n \tif (pp->fmt == CMIT_FMT_EMAIL) {\n \t\tint display_name_length;\n \n-\t\tdisplay_name_length = ident.name_end - ident.name_begin;\n+\t\tdisplay_name_length = strlen(person_name);\n \n \t\tstrbuf_addstr(sb, \"From: \");\n-\t\tif (needs_rfc2047_encoding(line, display_name_length, RFC2047_ADDRESS)) {\n-\t\t\tadd_rfc2047(sb, line, display_name_length,\n+\t\tif (needs_rfc2047_encoding(person_name, display_name_length, RFC2047_ADDRESS)) {\n+\t\t\tadd_rfc2047(sb, person_name, display_name_length,\n \t\t\t\t\t\tencoding, RFC2047_ADDRESS);\n \t\t\tmax_length = 76; /* per rfc2047 */\n-\t\t} else if (needs_rfc822_quoting(line, display_name_length)) {\n+\t\t} else if (needs_rfc822_quoting(person_name,\n+\t\t\t\t\t\tdisplay_name_length)) {\n \t\t\tstruct strbuf quoted = STRBUF_INIT;\n-\t\t\tadd_rfc822_quoted(&quoted, line, display_name_length);\n+\t\t\tadd_rfc822_quoted(&quoted, person_name,\n+\t\t\t\t\t  display_name_length);\n \t\t\tstrbuf_add_wrapped_bytes(sb, quoted.buf, quoted.len,\n \t\t\t\t\t\t\t-6, 1, max_length);\n \t\t\tstrbuf_release(&quoted);\n \t\t} else {\n-\t\t\tstrbuf_add_wrapped_bytes(sb, line, display_name_length,\n-\t\t\t\t\t\t\t-6, 1, max_length);\n+\t\t\tstrbuf_add_wrapped_bytes(sb, person_name,\n+\t\t\t\t\t\t display_name_length,\n+\t\t\t\t\t\t -6, 1, max_length);\n \t\t}\n-\t\tif (namelen - display_name_length + last_line_length(sb) > max_length) {\n+\t\tif (namelen - display_name_length + last_line_length(sb) > max_length)\n \t\t\tstrbuf_addch(sb, '\\n');\n-\t\t\tif (!isspace(ident.name_end[0]))\n-\t\t\t\tstrbuf_addch(sb, ' ');\n-\t\t}\n-\t\tstrbuf_add(sb, ident.name_end, namelen - display_name_length);\n+\n+\t\tstrbuf_addch(sb, ' ');\n+\t\tstrbuf_addch(sb, '<');\n+\t\tstrbuf_add(sb, person_mail, strlen(person_mail));\n+\t\tstrbuf_addch(sb, '>');\n \t\tstrbuf_addch(sb, '\\n');\n \t} else {\n-\t\tstrbuf_addf(sb, \"%s: %.*s%.*s\\n\", what,\n+\t\tstrbuf_addf(sb, \"%s: %.*s%s <%s>\\n\", what,\n \t\t\t      (pp->fmt == CMIT_FMT_FULLER) ? 4 : 0,\n-\t\t\t      \"    \", namelen, line);\n+\t\t\t    \"    \", person_name, person_mail);\n \t}\n \tswitch (pp->fmt) {\n \tcase CMIT_FMT_MEDIUM:\n-- \n1.8.1.rc1.5.g7e0651a\n"},{"id":"204697","messageId":"1355264493-8298-6-git-send-email-apelisse@gmail.com","threadId":"32317","inReplyTo":"1355264493-8298-1-git-send-email-apelisse@gmail.com","subject":"[PATCH 5/5] log: Add --use-mailmap option","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2012-12-11T22:21:33Z","receivedAt":"2012-12-11T22:21:33Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"Add the --use-mailmap option to log commands. It allows\nto display names from mailmap file when displaying logs,\nwhatever the format used.\n\nSigned-off-by: Antoine Pelisse <apelisse@gmail.com>\n---\n builtin/log.c | 9 ++++++++-\n 1 file changed, 8 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex e7b7db1..d2bd8ce 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -22,6 +22,7 @@\n #include \"branch.h\"\n #include \"streaming.h\"\n #include \"version.h\"\n+#include \"mailmap.h\"\n \n /* Set a default date-time format for git log (\"log.date\" config variable) */\n static const char *default_date_mode = NULL;\n@@ -94,11 +95,12 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n \t\t\t struct rev_info *rev, struct setup_revision_opt *opt)\n {\n \tstruct userformat_want w;\n-\tint quiet = 0, source = 0;\n+\tint quiet = 0, source = 0, mailmap = 0;\n \n \tconst struct option builtin_log_options[] = {\n \t\tOPT_BOOLEAN(0, \"quiet\", &quiet, N_(\"suppress diff output\")),\n \t\tOPT_BOOLEAN(0, \"source\", &source, N_(\"show source\")),\n+\t\tOPT_BOOLEAN(0, \"use-mailmap\", &mailmap, N_(\"Use mail map file\")),\n \t\t{ OPTION_CALLBACK, 0, \"decorate\", NULL, NULL, N_(\"decorate options\"),\n \t\t  PARSE_OPT_OPTARG, decorate_callback},\n \t\tOPT_END()\n@@ -136,6 +138,11 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n \tif (source)\n \t\trev->show_source = 1;\n \n+\tif (mailmap) {\n+\t\trev->mailmap = xcalloc(1, sizeof(struct string_list));\n+\t\tread_mailmap(rev->mailmap, NULL);\n+\t}\n+\n \tif (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {\n \t\t/*\n \t\t * \"log --pretty=raw\" is special; ignore UI oriented\n-- \n1.8.1.rc1.5.g7e0651a\n"},{"id":"204700","messageId":"7vip886wyr.fsf@alter.siamese.dyndns.org","threadId":"32317","inReplyTo":"1355264493-8298-1-git-send-email-apelisse@gmail.com","subject":"Re: [PATCH 0/5] Allow git log to use mailmap file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-11T22:33:00Z","receivedAt":"2012-12-11T22:33:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Antoine Pelisse <apelisse@gmail.com> writes:\n\n> Implement the feature suggested here [1] by Rich Mindwinter\n> and Junio C Hamano (and following his advices)\n>\n> This is a pre-version so there are a bunch of things still missing,\n> among them:\n>  - There is no tests\n>  - Grep search for mailmap author/committer is not available\n>  - There is no documentation of the new option\n>\n> [1]: http://thread.gmane.org/gmane.comp.version-control.git/211270\n\nThat was quick ;-)\n\n> Antoine Pelisse (5):\n>   Use split_ident_line to parse author and committer\n>   mailmap: Remove buffer length limit in map_user\n>   mailmap: Add mailmap structure to rev_info and pp\n>   pretty: Use mailmap to display username and email\n>   log: Add --use-mailmap option\n>\n>  builtin/blame.c | 59 +++++++++++++++++-------------------------------\n>  builtin/log.c   |  9 +++++++-\n>  commit.h        |  1 +\n>  log-tree.c      |  1 +\n>  mailmap.c       | 16 ++++++-------\n>  pretty.c        | 70 ++++++++++++++++++++++++++++++++++++---------------------\n>  revision.h      |  1 +\n>  7 files changed, 84 insertions(+), 73 deletions(-)\n>\n> --\n> 1.8.1.rc1.5.g7e0651a\n"},{"id":"204701","messageId":"CALKB1SXOqYmynv7EgezeL7-epsiB7OnSYKhHyS_u8UWOhJgUsQ@mail.gmail.com","threadId":"32317","inReplyTo":"7vip886wyr.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 0/5] Allow git log to use mailmap file","fromName":"Rich Midwinter","fromEmail":"rich.midwinter@gmail.com","sentAt":"2012-12-11T22:41:56Z","receivedAt":"2012-12-11T22:41:56Z","isPatch":true,"sender":{"key":"rich.midwinter@gmail.com","avatar":null},"body":"It certainly was. Thanks for picking this up so quick guys.\n\nOn 11 December 2012 22:33, Junio C Hamano <gitster@pobox.com> wrote:\n> Antoine Pelisse <apelisse@gmail.com> writes:\n>\n>> Implement the feature suggested here [1] by Rich Mindwinter\n>> and Junio C Hamano (and following his advices)\n>>\n>> This is a pre-version so there are a bunch of things still missing,\n>> among them:\n>>  - There is no tests\n>>  - Grep search for mailmap author/committer is not available\n>>  - There is no documentation of the new option\n>>\n>> [1]: http://thread.gmane.org/gmane.comp.version-control.git/211270\n>\n> That was quick ;-)\n>\n>> Antoine Pelisse (5):\n>>   Use split_ident_line to parse author and committer\n>>   mailmap: Remove buffer length limit in map_user\n>>   mailmap: Add mailmap structure to rev_info and pp\n>>   pretty: Use mailmap to display username and email\n>>   log: Add --use-mailmap option\n>>\n>>  builtin/blame.c | 59 +++++++++++++++++-------------------------------\n>>  builtin/log.c   |  9 +++++++-\n>>  commit.h        |  1 +\n>>  log-tree.c      |  1 +\n>>  mailmap.c       | 16 ++++++-------\n>>  pretty.c        | 70 ++++++++++++++++++++++++++++++++++++---------------------\n>>  revision.h      |  1 +\n>>  7 files changed, 84 insertions(+), 73 deletions(-)\n>>\n>> --\n>> 1.8.1.rc1.5.g7e0651a\n"},{"id":"204702","messageId":"7vehiw6wc1.fsf@alter.siamese.dyndns.org","threadId":"32317","inReplyTo":"1355264493-8298-5-git-send-email-apelisse@gmail.com","subject":"Re: [PATCH 4/5] pretty: Use mailmap to display username and email","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-11T22:46:38Z","receivedAt":"2012-12-11T22:46:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Antoine Pelisse <apelisse@gmail.com> writes:\n\n> Use the mailmap information to display the correct\n> username and email address in all log commands.\n>\n> Signed-off-by: Antoine Pelisse <apelisse@gmail.com>\n> ---\n>  pretty.c | 46 +++++++++++++++++++++++++++++++---------------\n>  1 file changed, 31 insertions(+), 15 deletions(-)\n>\n> diff --git a/pretty.c b/pretty.c\n> index 6730add..e232aaa 100644\n> --- a/pretty.c\n> +++ b/pretty.c\n> @@ -387,6 +387,8 @@ void pp_user_info(const struct pretty_print_context *pp,\n>  \t\t  const char *what, struct strbuf *sb,\n>  \t\t  const char *line, const char *encoding)\n>  {\n> +\tchar person_name[1024];\n> +\tchar person_mail[1024];\n>  \tstruct ident_split ident;\n>  \tint linelen, namelen;\n>  \tchar *line_end, *date;\n> @@ -405,41 +407,55 @@ void pp_user_info(const struct pretty_print_context *pp,\n>  \tif (split_ident_line(&ident, line, linelen))\n>  \t\treturn;\n>  \n> -\tnamelen = ident.mail_end - ident.name_begin + 1;\n> +\tmemcpy(person_mail, ident.mail_begin, ident.mail_end - ident.mail_begin);\n> +\tperson_mail[ident.mail_end - ident.mail_begin] = 0;\n> +\n> +\tmemcpy(person_name, ident.name_begin, ident.name_end - ident.name_begin);\n> +\tperson_name[ident.name_end - ident.name_begin] = 0;\n> +\n> +\tif (pp->mailmap)\n> +\t\tmap_user(pp->mailmap, person_mail, sizeof(person_mail),\n> +\t\t\t person_name, sizeof(person_name));\n\nThis is why I said that we may want to rethink the API signature of\nthe map_user() function.  Now this caller has the hardcoded limit\nfor name and mail parts, and it needs to make copies of strings into\ntwo arrays only because map_user() expects to get two fixed-size\nbuffers that are to be rewritten in-place.  If we changed map_user()\nto take two strbufs (one for name, the other for mail) to be updated\nin place, we would still need to make copies, but later code in this\nfunction may be able to lose a few strlen() calls.\n\nOr it might be better to make those two strbufs output-only\nparameter, e.g.\n\n\tmap_user(struct string_list *mailmap,\n        \tconst char *name, size_t namelen,\n                const char *mail, size_t maillen,\n                struct strbuf *name_out, struct strbuf *mail_out);\n\nthen after split_ident_line(), this caller could feed two pointers\ninto the original \"line\" as name and mail parameter, without making\nany copies (the callee has to make a copy but it has to be done\nanyway when the name/mail is mapped).  I suspect it would make this\ncaller simpler, but I do not know how invasive such changes are for\nother callers of map_user().\n\nSuch an update can be left outside of this series, of course.\n\n> +\t\tstrbuf_addch(sb, ' ');\n> +\t\tstrbuf_addch(sb, '<');\n> +\t\tstrbuf_add(sb, person_mail, strlen(person_mail));\n> +\t\tstrbuf_addch(sb, '>');\n>  \t\tstrbuf_addch(sb, '\\n');\n\nIs that strbuf_addf(sb, \" <%s>\\n\", person_mail)?\n"},{"id":"204735","messageId":"CALWbr2xmRVS9m623yrxY88Ftaen_B8Tb2vd+VxhYV1ceAmbDSg@mail.gmail.com","threadId":"32317","inReplyTo":"1355264493-8298-6-git-send-email-apelisse@gmail.com","subject":"Re: [PATCH 5/5] log: Add --use-mailmap option","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2012-12-12T11:58:59Z","receivedAt":"2012-12-12T11:58:59Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"On Tue, Dec 11, 2012 at 11:21 PM, Antoine Pelisse <apelisse@gmail.com> wrote:\n> Add the --use-mailmap option to log commands. It allows\n> to display names from mailmap file when displaying logs,\n> whatever the format used.\n\nThe question is which log commands actually ?\nShouldn't we put the option in revision.c::handle_revision_opt instead ?\nMy opinion is that it belongs to 'Commit Formatting'.\nIt would also make sense to be able to use '--use-mailmap' when running\nformat-patch for example.\n\nAlso, I've noticed that my series break some tests (linked with\nformat-patch BTW).\nI fixed that and re-ran all tests successfully. I will resubmit it later.\n"},{"id":"204742","messageId":"CALWbr2w65iAnegu-VSLWo1Ckh9q8291aVVjchcXaz1A24bLcEA@mail.gmail.com","threadId":"32317","inReplyTo":"7vehiw6wc1.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 4/5] pretty: Use mailmap to display username and email","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2012-12-12T13:27:24Z","receivedAt":"2012-12-12T13:27:24Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"> Or it might be better to make those two strbufs output-only\n> parameter, e.g.\n>\n>         map_user(struct string_list *mailmap,\n>                 const char *name, size_t namelen,\n>                 const char *mail, size_t maillen,\n>                 struct strbuf *name_out, struct strbuf *mail_out);\n>\n> then after split_ident_line(), this caller could feed two pointers\n> into the original \"line\" as name and mail parameter, without making\n> any copies (the callee has to make a copy but it has to be done\n> anyway when the name/mail is mapped).  I suspect it would make this\n> caller simpler, but I do not know how invasive such changes are for\n> other callers of map_user().\n\nIt makes a lot of sense.\nblame.c::get_commit_info() hard code the length\nshortlog.c::insert_one_record() hard code the length\npretty.c::format_person_part() hard code the length\n\nI don't think it will be invasive.\n\n> Such an update can be left outside of this series, of course.\n\nI will try to make it at the beginning of the series. It will avoid unnecessary\nconflicts.\n\n>> +             strbuf_addch(sb, ' ');\n>> +             strbuf_addch(sb, '<');\n>> +             strbuf_add(sb, person_mail, strlen(person_mail));\n>> +             strbuf_addch(sb, '>');\n>>               strbuf_addch(sb, '\\n');\n>\n> Is that strbuf_addf(sb, \" <%s>\\n\", person_mail)?\n\nOf couse ;) Fixed.\n"},{"id":"204764","messageId":"7vd2yf5f01.fsf@alter.siamese.dyndns.org","threadId":"32317","inReplyTo":"CALWbr2xmRVS9m623yrxY88Ftaen_B8Tb2vd+VxhYV1ceAmbDSg@mail.gmail.com","subject":"Re: [PATCH 5/5] log: Add --use-mailmap option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-12T17:58:38Z","receivedAt":"2012-12-12T17:58:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Antoine Pelisse <apelisse@gmail.com> writes:\n\n> On Tue, Dec 11, 2012 at 11:21 PM, Antoine Pelisse <apelisse@gmail.com> wrote:\n>> Add the --use-mailmap option to log commands. It allows\n>> to display names from mailmap file when displaying logs,\n>> whatever the format used.\n>\n> The question is which log commands actually ?\n> Shouldn't we put the option in revision.c::handle_revision_opt instead ?\n\nI was trying to avoid that to make it harder to trigger the\n\"feature\" by mistake.  The rewriting with mailmap is for human\nconsumption and when we replay the history (e.g. format-patch used\nas input for am or rebase), we should never be applying it.\n"}]}