diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-07-15 18:59:04 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-07-15 18:59:04 -0700 |
commit | fab600ce2ed086ba87499ffe3c35c46f85e7ab61 (patch) | |
tree | ee50aef079f3aaeb9094cf3bb70a545fe809cb4c /pretty.c | |
parent | 28ed6e7b321bee3dd7e4aa9c0ff7da64844136f6 (diff) | |
parent | e0cbc39768884a1e7edcf2dbf6e6825c4b23485a (diff) | |
download | git-fab600ce2ed086ba87499ffe3c35c46f85e7ab61.tar.gz |
Merge branch 'js/maint-pretty-mailmap'
* js/maint-pretty-mailmap:
Add pretty format %aN which gives the author name, respecting .mailmap
Diffstat (limited to 'pretty.c')
-rw-r--r-- | pretty.c | 27 |
1 files changed, 25 insertions, 2 deletions
@@ -3,6 +3,8 @@ #include "utf8.h" #include "diff.h" #include "revision.h" +#include "path-list.h" +#include "mailmap.h" static char *user_format; @@ -288,6 +290,25 @@ static char *logmsg_reencode(const struct commit *commit, return out; } +static int mailmap_name(struct strbuf *sb, const char *email) +{ + static struct path_list *mail_map; + char buffer[1024]; + + if (!mail_map) { + mail_map = xcalloc(1, sizeof(*mail_map)); + read_mailmap(mail_map, ".mailmap", NULL); + } + + if (!mail_map->nr) + return -1; + + if (!map_email(mail_map, email, buffer, sizeof(buffer))) + return -1; + strbuf_addstr(sb, buffer); + return 0; +} + static size_t format_person_part(struct strbuf *sb, char part, const char *msg, int len) { @@ -309,10 +330,12 @@ static size_t format_person_part(struct strbuf *sb, char part, if (end >= len - 2) goto skip; - if (part == 'n') { /* name */ + if (part == 'n' || part == 'N') { /* name */ while (end > 0 && isspace(msg[end - 1])) end--; - strbuf_add(sb, msg, end); + if (part != 'N' || !msg[end] || !msg[end + 1] || + mailmap_name(sb, msg + end + 2) < 0) + strbuf_add(sb, msg, end); return placeholder_len; } start = ++end; /* save email start position */ |