[RFC/PATCH] Use mailmap by default in log, show and whatchanged
- Date: Thu, 13 Dec 2018 12:09:40 +0000
- From: CB Bailey <cb@xxxxxxxxxxxxx>
- Subject: [RFC/PATCH] Use mailmap by default in log, show and whatchanged
From: CB Bailey <cbailey32@xxxxxxxxxxxxx>
People who have changed their name or email address will usually know
that they need to set 'log.mailmap' in order to have their new details
reflected for old commits with 'git log', but others who interact with
them may not know or care enough to enable this option.
Change the default for 'git log' and friends to always use mailmap so
that everyone gets to see canonical names and email addresses.
Signed-off-by: CB Bailey <cbailey32@xxxxxxxxxxxxx>
Related to my patch to make shortlog pass the mailmap into the revision
walker which may end up being configuratble behavior, I thought I'd
propose this for discussion.
For people who change their names during their involvement in a project,
it can be important that the people with whom they work only see their
correct name, even when browsing old history.
I had a dig around in the mailing list archives and couldn't find any
specific reason not to use a mailmap in log where one is in use. I did
find this message which suggests that it makes sense to make it the
default for human-consumed formats. This patch doesn't affect
Documentation/config/log.txt | 4 ++--
Documentation/git-log.txt | 12 +++++++++---
builtin/log.c | 2 +-
t/t4203-mailmap.sh | 18 ++++++++++++++++++
4 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/Documentation/config/log.txt b/Documentation/config/log.txt
index 78d9e4453a..8a01eed46b 100644
@@ -39,5 +39,5 @@ log.showSignature::
linkgit:git-whatchanged assume `--show-signature`.
- If true, makes linkgit:git-log, linkgit:git-show, and
- linkgit:git-whatchanged assume `--use-mailmap`.
+ If false, makes linkgit:git-log, linkgit:git-show, and
+ linkgit:git-whatchanged assume `--no-use-mailmap`.
diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index 90761f1694..7815c9a6cb 100644
@@ -50,9 +50,11 @@ OPTIONS
commit was reached.
- Use mailmap file to map author and committer names and email
- addresses to canonical real names and email addresses. See
+ Use (or don't use) mailmap file to map author and committer names and
+ email addresses to canonical real names and email addresses. The default
+ is to use the mailmap file, but this can be overriden with the
+ `log.mailmap` configuration option. See linkgit:git-shortlog.
Without this flag, `git log -p <path>...` shows commits that
@@ -205,6 +207,10 @@ log.showRoot::
`git log -p` output would be shown without a diff attached.
The default is `true`.
+ If `false`, makes `git log` and related commands assume
If `true`, `git log` and related commands will act as if the
`--show-signature` option was passed to them.
diff --git a/builtin/log.c b/builtin/log.c
index e8e51068bd..41a5eefb20 100644
@@ -46,7 +46,7 @@ static int default_follow;
static int default_show_signature;
static int decoration_style;
static int decoration_given;
-static int use_mailmap_config;
+static int use_mailmap_config = 1;
static const char *fmt_patch_subject_prefix = "PATCH";
static const char *fmt_pretty;
diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 43b1522ea2..efb145c4cd 100755
@@ -424,6 +424,24 @@ EOF
test_expect_success 'Log output with --use-mailmap' '
git log --use-mailmap | grep Author >actual &&
+ test_cmp expect actual &&
+# --use-mailmap is the default
+ git log | grep Author >actual &&
+ test_cmp expect actual
+cat >expect <<\EOF
+Author: CTO <cto@xxxxxxxxxxx>
+Author: claus <me@xxxxxxxxxx>
+Author: santa <me@xxxxxxxxxx>
+Author: nick2 <nick2@xxxxxxxxxx>
+Author: nick2 <bugs@xxxxxxxxxx>
+Author: nick1 <bugs@xxxxxxxxxx>
+Author: A U Thor <author@xxxxxxxxxxx>
+test_expect_success 'Log output with --no-use-mailmap' '
+ git log --no-use-mailmap | grep Author >actual &&
test_cmp expect actual