Skip to content

Commit ea57bc0

Browse files
apelissegitster
authored andcommitted
log: add --use-mailmap option
Add the --use-mailmap option to log commands. It allows to display names from mailmap file when displaying logs, whatever the format used. Signed-off-by: Antoine Pelisse <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dffd325 commit ea57bc0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Documentation/git-log.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ OPTIONS
4747
Print out the ref name given on the command line by which each
4848
commit was reached.
4949

50+
--use-mailmap::
51+
Use mailmap file to map author and committer names and email
52+
to canonical real names and email addresses. See
53+
linkgit:git-shortlog[1].
54+
5055
--full-diff::
5156
Without this flag, "git log -p <path>..." shows commits that
5257
touch the specified paths, and diffs about the same specified

builtin/log.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "branch.h"
2323
#include "streaming.h"
2424
#include "version.h"
25+
#include "mailmap.h"
2526

2627
/* Set a default date-time format for git log ("log.date" config variable) */
2728
static const char *default_date_mode = NULL;
@@ -94,11 +95,12 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
9495
struct rev_info *rev, struct setup_revision_opt *opt)
9596
{
9697
struct userformat_want w;
97-
int quiet = 0, source = 0;
98+
int quiet = 0, source = 0, mailmap = 0;
9899

99100
const struct option builtin_log_options[] = {
100101
OPT_BOOLEAN(0, "quiet", &quiet, N_("suppress diff output")),
101102
OPT_BOOLEAN(0, "source", &source, N_("show source")),
103+
OPT_BOOLEAN(0, "use-mailmap", &mailmap, N_("Use mail map file")),
102104
{ OPTION_CALLBACK, 0, "decorate", NULL, NULL, N_("decorate options"),
103105
PARSE_OPT_OPTARG, decorate_callback},
104106
OPT_END()
@@ -136,6 +138,11 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
136138
if (source)
137139
rev->show_source = 1;
138140

141+
if (mailmap) {
142+
rev->mailmap = xcalloc(1, sizeof(struct string_list));
143+
read_mailmap(rev->mailmap, NULL);
144+
}
145+
139146
if (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {
140147
/*
141148
* "log --pretty=raw" is special; ignore UI oriented

0 commit comments

Comments
 (0)