path: root/builtin
diff options
authorAntoine Pelisse <>2013-08-23 13:48:31 (GMT)
committerJunio C Hamano <>2013-08-25 05:17:39 (GMT)
commitea16794e4303e79f8acb01a93fb6b1762972ab86 (patch)
treeb7cfced09a5db569eccaf9d40a00a41603ef8389 /builtin
parent0d8beaa5b76e824c9869f0d1f1b19ec7acf4982f (diff)
commit: search author pattern against mailmap
"git commit --author=$name" sets the author to one whose name matches the given string from existing commits, when $name is not in the "Name <e-mail>" format. However, it does not honor the mailmap to use the canonical name for the author found this way. Fix it by telling the logic to find a matching existing author to honor the mailmap, and use the name and email after applying the mailmap. Signed-off-by: Antoine Pelisse <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin')
1 files changed, 7 insertions, 1 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index 10acc53..a48a7fe 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -30,6 +30,7 @@
#include "column.h"
#include "sequencer.h"
#include "notes-utils.h"
+#include "mailmap.h"
static const char * const builtin_commit_usage[] = {
N_("git commit [options] [--] <pathspec>..."),
@@ -935,6 +936,7 @@ static const char *find_author_by_nickname(const char *name)
struct rev_info revs;
struct commit *commit;
struct strbuf buf = STRBUF_INIT;
+ struct string_list mailmap = STRING_LIST_INIT_NODUP;
const char *av[20];
int ac = 0;
@@ -945,13 +947,17 @@ static const char *find_author_by_nickname(const char *name)
av[++ac] = buf.buf;
av[++ac] = NULL;
setup_revisions(ac, av, &revs, NULL);
+ revs.mailmap = &mailmap;
+ read_mailmap(revs.mailmap, NULL);
commit = get_revision(&revs);
if (commit) {
struct pretty_print_context ctx = {0};
ctx.date_mode = DATE_NORMAL;
- format_commit_message(commit, "%an <%ae>", &buf, &ctx);
+ format_commit_message(commit, "%aN <%aE>", &buf, &ctx);
+ clear_mailmap(&mailmap);
return strbuf_detach(&buf, NULL);
die(_("No existing author found with '%s'"), name);