diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-07-16 15:27:03 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-07-16 15:27:03 -0700 |
commit | 013942f637e2e0706b5a44e58a9d285bc57c5305 (patch) | |
tree | f9919df4ac540b042a57bb1a5cd16fc139f53517 | |
parent | c9784cd0c8576ccbacb3d7dd14000d0892c3fdf6 (diff) | |
parent | e0cbc39768884a1e7edcf2dbf6e6825c4b23485a (diff) | |
download | git-013942f637e2e0706b5a44e58a9d285bc57c5305.tar.gz git-013942f637e2e0706b5a44e58a9d285bc57c5305.tar.xz |
Merge branch 'js/maint-pretty-mailmap' into maint
* js/maint-pretty-mailmap:
Add pretty format %aN which gives the author name, respecting .mailmap
-rw-r--r-- | Documentation/pretty-formats.txt | 2 | ||||
-rw-r--r-- | pretty.c | 27 |
2 files changed, 27 insertions, 2 deletions
diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt index 69e6d2fa4..c11d49577 100644 --- a/Documentation/pretty-formats.txt +++ b/Documentation/pretty-formats.txt @@ -101,6 +101,7 @@ The placeholders are: - '%P': parent hashes - '%p': abbreviated parent hashes - '%an': author name +- '%aN': author name (respecting .mailmap) - '%ae': author email - '%ad': author date - '%aD': author date, RFC2822 style @@ -108,6 +109,7 @@ The placeholders are: - '%at': author date, UNIX timestamp - '%ai': author date, ISO 8601 format - '%cn': committer name +- '%cN': committer name (respecting .mailmap) - '%ce': committer email - '%cd': committer date - '%cD': committer date, RFC2822 style @@ -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 */ |