git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / Atom feed
* [PATCH v3 0/3] use mailmap by default in git log
@ 2019-07-11 18:06 Ariadne Conill
  2019-07-11 18:06 ` [PATCH v3 1/3] log: use mailmap by default Ariadne Conill
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ariadne Conill @ 2019-07-11 18:06 UTC (permalink / raw)
  To: git; +Cc: Ariadne Conill

It is not uncommon for people to change their name or e-mail address.
To facilitate this, Git provides support for the `.mailmap` file,
which contains a list of identities and previously used e-mail
addresses that are associated with that identity.

Unfortunately, while Git's support for the `.mailmap` file is generally
excellent, I recently discovered that `git log` does not treat the
mail map file the same as the other tools, instead requiring an
explicit flag to use the mailmap file.

I believe this is an unfortunate flaw, as the mailmap file should
ideally contain the most current known contact information for a
contributor, allowing anyone to contact the contributor about their
patches in the future.

New in version 3:
- Rework many mailmap tests to drop redundant `--use-mailmap` and
  more rigorously test --no-use-mailmap and configuration variants.
- Typo fixes in the commit messages.

New in version 2:
- The `--no-use-mailmap` option, which complements `--use-mailmap`.
- Tests for `--no-use-mailmap`.

Ariadne Conill (3):
  log: use mailmap by default
  log: add --no-use-mailmap option to complement --use-mailmap option
  tests: rework mailmap tests for git log

 Documentation/git-log.txt |  5 ++++
 builtin/log.c             |  3 ++-
 t/t4203-mailmap.sh        | 49 ++++++++++++++++++++++++++++++++-------
 3 files changed, 48 insertions(+), 9 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 1/3] log: use mailmap by default
  2019-07-11 18:06 [PATCH v3 0/3] use mailmap by default in git log Ariadne Conill
@ 2019-07-11 18:06 ` Ariadne Conill
  2019-07-11 18:06 ` [PATCH v3 2/3] log: add --no-use-mailmap option to complement --use-mailmap option Ariadne Conill
  2019-07-11 18:06 ` [PATCH v3 3/3] tests: rework mailmap tests for git log Ariadne Conill
  2 siblings, 0 replies; 4+ messages in thread
From: Ariadne Conill @ 2019-07-11 18:06 UTC (permalink / raw)
  To: git; +Cc: Ariadne Conill

The `git log` command shows the author and committer name recorded in
the git repository itself, while other commands respect `.mailmap`
by default.  I believe this is a bad design: it causes log entries to
reflect inaccurate information: anyone who changes their name or
e-mail address will not have that change (recorded in mailmap file)
reflected when using `git log` by default.

Anyone who explicitly wants the current behaviour can clearly request
it by setting the `log.mailmap` setting to `false` in their
`.gitconfig` file.

Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
---
 builtin/log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/log.c b/builtin/log.c
index 7c8767d3bc..3d2ce8fa3d 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -47,7 +47,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;
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 2/3] log: add --no-use-mailmap option to complement --use-mailmap option
  2019-07-11 18:06 [PATCH v3 0/3] use mailmap by default in git log Ariadne Conill
  2019-07-11 18:06 ` [PATCH v3 1/3] log: use mailmap by default Ariadne Conill
@ 2019-07-11 18:06 ` Ariadne Conill
  2019-07-11 18:06 ` [PATCH v3 3/3] tests: rework mailmap tests for git log Ariadne Conill
  2 siblings, 0 replies; 4+ messages in thread
From: Ariadne Conill @ 2019-07-11 18:06 UTC (permalink / raw)
  To: git; +Cc: Ariadne Conill

When mailmap is enabled by default or by configuration, it may be
useful to override the default behaviour.  Previously, it was
possible to enable the mailmap feature when it was disabled by
default or in the configuration, but it was not possible to disable
the mailmap feature when it was enabled by default or by the
configuration.

The --no-use-mailmap option equalizes this by allowing the user to
explicitly enable or disable the mailmap feature according to their
requirements.

Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
---
 Documentation/git-log.txt | 5 +++++
 builtin/log.c             | 1 +
 2 files changed, 6 insertions(+)

diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index b02e922dc3..50bc8f7da2 100644
--- a/Documentation/git-log.txt
+++ b/Documentation/git-log.txt
@@ -54,6 +54,11 @@ OPTIONS
 	addresses to canonical real names and email addresses. See
 	linkgit:git-shortlog[1].
 
+--no-use-mailmap::
+	Do not use the mailmap file to map author and commiter names
+	and email addresses to canonical real names and email addresses.
+	See linkgit:git-shortlog[1].
+
 --full-diff::
 	Without this flag, `git log -p <path>...` shows commits that
 	touch the specified paths, and diffs about the same specified
diff --git a/builtin/log.c b/builtin/log.c
index 3d2ce8fa3d..a9195bcb34 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -167,6 +167,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
 		OPT__QUIET(&quiet, N_("suppress diff output")),
 		OPT_BOOL(0, "source", &source, N_("show source")),
 		OPT_BOOL(0, "use-mailmap", &mailmap, N_("Use mail map file")),
+		OPT_NEGBIT(0, "no-use-mailmap", &mailmap, N_("Do not use mail map file"), 1),
 		OPT_STRING_LIST(0, "decorate-refs", &decorate_refs_include,
 				N_("pattern"), N_("only decorate refs that match <pattern>")),
 		OPT_STRING_LIST(0, "decorate-refs-exclude", &decorate_refs_exclude,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 3/3] tests: rework mailmap tests for git log
  2019-07-11 18:06 [PATCH v3 0/3] use mailmap by default in git log Ariadne Conill
  2019-07-11 18:06 ` [PATCH v3 1/3] log: use mailmap by default Ariadne Conill
  2019-07-11 18:06 ` [PATCH v3 2/3] log: add --no-use-mailmap option to complement --use-mailmap option Ariadne Conill
@ 2019-07-11 18:06 ` Ariadne Conill
  2 siblings, 0 replies; 4+ messages in thread
From: Ariadne Conill @ 2019-07-11 18:06 UTC (permalink / raw)
  To: git; +Cc: Ariadne Conill

In order to prove that the --no-use-mailmap option works as expected,
we add a test for it which runs with -c log.mailmap=true to ensure that
the option successfully negates the configured default.

Additionally, since --use-mailmap is now the default behaviour, we
remove mentions of --use-mailmap from the tests, since they are
redundant.  We also rework some tests to explicitly define the
log.mailmap variable in both true and false states.

Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
---
 t/t4203-mailmap.sh | 49 ++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 41 insertions(+), 8 deletions(-)

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 43b1522ea2..3d6086ff96 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -422,8 +422,8 @@ Author: Some Dude <some@dude.xx>
 Author: A U Thor <author@example.com>
 EOF
 
-test_expect_success 'Log output with --use-mailmap' '
-	git log --use-mailmap | grep Author >actual &&
+test_expect_success 'Log output with mailmap enabled (default)' '
+	git log | grep Author >actual &&
 	test_cmp expect actual
 '
 
@@ -437,18 +437,33 @@ Author: Some Dude <some@dude.xx>
 Author: A U Thor <author@example.com>
 EOF
 
-test_expect_success 'Log output with log.mailmap' '
+test_expect_success 'Log output with log.mailmap enabled in config' '
 	git -c log.mailmap=True log | grep Author >actual &&
 	test_cmp expect actual
 '
 
+cat >expect <<\EOF
+Author: CTO <cto@coompany.xx>
+Author: claus <me@company.xx>
+Author: santa <me@company.xx>
+Author: nick2 <nick2@company.xx>
+Author: nick2 <bugs@company.xx>
+Author: nick1 <bugs@company.xx>
+Author: A U Thor <author@example.com>
+EOF
+
+test_expect_success 'Log output with log.mailmap disabled in config' '
+	git -c log.mailmap=False log | grep Author >actual &&
+	test_cmp expect actual
+'
+
 cat >expect <<\EOF
 Author: Santa Claus <santa.claus@northpole.xx>
 Author: Santa Claus <santa.claus@northpole.xx>
 EOF
 
-test_expect_success 'Grep author with --use-mailmap' '
-	git log --use-mailmap --author Santa | grep Author >actual &&
+test_expect_success 'Grep author with mailmap enabled (default)' '
+	git log --author Santa | grep Author >actual &&
 	test_cmp expect actual
 '
 cat >expect <<\EOF
@@ -456,16 +471,34 @@ Author: Santa Claus <santa.claus@northpole.xx>
 Author: Santa Claus <santa.claus@northpole.xx>
 EOF
 
-test_expect_success 'Grep author with log.mailmap' '
+test_expect_success 'Grep author with log.mailmap enabled' '
 	git -c log.mailmap=True log --author Santa | grep Author >actual &&
 	test_cmp expect actual
 '
 
-test_expect_success 'Only grep replaced author with --use-mailmap' '
-	git log --use-mailmap --author "<cto@coompany.xx>" >actual &&
+test_expect_success 'Grep author with log.mailmap disabled' '
+	git -c log.mailmap=False log --author "<santa.claus@northpole.xx>" >actual &&
+	test_must_be_empty actual
+'
+
+test_expect_success 'Grep author with --no-use-mailmap' '
+	git log --no-use-mailmap --author "<santa.claus@northpole.xx>" >actual &&
 	test_must_be_empty actual
 '
 
+test_expect_success 'Only grep replaced author with mailmap enabled' '
+	git log --author "<cto@coompany.xx>" >actual &&
+	test_must_be_empty actual
+'
+cat >expect <<\EOF
+Author: santa <me@company.xx>
+EOF
+
+test_expect_success 'Grep author with --no-use-mailmap + log.mailmap=True' '
+	git -c log.mailmap=True log --no-use-mailmap --author santa | grep Author >actual &&
+	test_cmp expect actual
+'
+
 # git blame
 cat >expect <<\EOF
 ^OBJI (A U Thor     DATE 1) one
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-11 18:06 [PATCH v3 0/3] use mailmap by default in git log Ariadne Conill
2019-07-11 18:06 ` [PATCH v3 1/3] log: use mailmap by default Ariadne Conill
2019-07-11 18:06 ` [PATCH v3 2/3] log: add --no-use-mailmap option to complement --use-mailmap option Ariadne Conill
2019-07-11 18:06 ` [PATCH v3 3/3] tests: rework mailmap tests for git log Ariadne Conill

git@vger.kernel.org list mirror (unofficial, one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox