Web lists-archives.com

[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
"--pretty=raw" formatting.

 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
--- a/Documentation/config/log.txt
+++ b/Documentation/config/log.txt
@@ -39,5 +39,5 @@ log.showSignature::
 	linkgit:git-whatchanged[1] assume `--show-signature`.
 
 log.mailmap::
-	If true, makes linkgit:git-log[1], linkgit:git-show[1], and
-	linkgit:git-whatchanged[1] assume `--use-mailmap`.
+	If false, makes linkgit:git-log[1], linkgit:git-show[1], and
+	linkgit:git-whatchanged[1] assume `--no-use-mailmap`.
diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index 90761f1694..7815c9a6cb 100644
--- a/Documentation/git-log.txt
+++ b/Documentation/git-log.txt
@@ -50,9 +50,11 @@ OPTIONS
 	commit was reached.
 
 --use-mailmap::
-	Use mailmap file to map author and committer names and email
-	addresses to canonical real names and email addresses. See
-	linkgit:git-shortlog[1].
+--no-use-mailmap::
+	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[1].
 
 --full-diff::
 	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`.
 
+log.mailmap::
+	If `false`, makes `git log` and related commands assume
+	`--no-use-mailmap`.
+
 log.showSignature::
 	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
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -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
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -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>
+EOF
+
+test_expect_success 'Log output with --no-use-mailmap' '
+	git log --no-use-mailmap | grep Author >actual &&
 	test_cmp expect actual
 '
 
-- 
2.20.0