log: really flip the --mailmap default
Update the docs, test the interaction between the new default, configuration and command line option, in addition to actually flipping the default. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Aug 1, 2019 at 14:48 UTC
f3eda90ffc10f9152e7492a34408a9f5e4c28b0f
3 files changed
+36
-6
Documentation/config/log.txt
+1
-1
@@ -41,4 +41,4 @@ log.showSignature::
41
log.mailmap::
42
If true, makes linkgit:git-log[1], linkgit:git-show[1], and
43
linkgit:git-whatchanged[1] assume `--use-mailmap`, otherwise
44
- assume `--no-use-mailmap`. False by default.
44
+ assume `--no-use-mailmap`. True by default.
builtin/log.c
+2
-5
@@ -47,7 +47,7 @@ static int default_follow;
47
static int default_show_signature;
48
static int decoration_style;
49
static int decoration_given;
50
-static int use_mailmap_config = -1;
50
+static int use_mailmap_config = 1;
51
static const char *fmt_patch_subject_prefix = "PATCH";
52
static const char *fmt_pretty;
53
@@ -160,7 +160,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
160
struct rev_info *rev, struct setup_revision_opt *opt)
161
{
162
struct userformat_want w;
163
- int quiet = 0, source = 0, mailmap = 0;
163
+ int quiet = 0, source = 0, mailmap;
164
static struct line_opt_callback_data line_cb = {NULL, NULL, STRING_LIST_INIT_DUP};
165
static struct string_list decorate_refs_exclude = STRING_LIST_INIT_NODUP;
166
static struct string_list decorate_refs_include = STRING_LIST_INIT_NODUP;
@@ -204,9 +204,6 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
204
memset(&w, 0, sizeof(w));
205
userformat_find_requirements(NULL, &w);
206
207
- if (mailmap < 0)
208
- mailmap = 0;
209
-
207
if (!rev->show_notes_given && (!rev->pretty_given || w.notes))
208
rev->show_notes = 1;
209
if (rev->show_notes)
t/t4203-mailmap.sh
+33
@@ -442,6 +442,34 @@ test_expect_success 'Log output with log.mailmap' '
442
test_cmp expect actual
443
'
444
445
+test_expect_success 'log.mailmap=false disables mailmap' '
446
+ cat >expect <<-\EOF &&
447
+ Author: CTO <cto@coompany.xx>
448
+ Author: claus <me@company.xx>
449
+ Author: santa <me@company.xx>
450
+ Author: nick2 <nick2@company.xx>
451
+ Author: nick2 <bugs@company.xx>
452
+ Author: nick1 <bugs@company.xx>
453
+ Author: A U Thor <author@example.com>
454
+ EOF
455
+ git -c log.mailmap=False log | grep Author > actual &&
456
+ test_cmp expect actual
457
+'
458
+
459
+test_expect_success '--no-use-mailmap disables mailmap' '
460
+ cat >expect <<-\EOF &&
461
+ Author: CTO <cto@coompany.xx>
462
+ Author: claus <me@company.xx>
463
+ Author: santa <me@company.xx>
464
+ Author: nick2 <nick2@company.xx>
465
+ Author: nick2 <bugs@company.xx>
466
+ Author: nick1 <bugs@company.xx>
467
+ Author: A U Thor <author@example.com>
468
+ EOF
469
+ git log --no-use-mailmap | grep Author > actual &&
470
+ test_cmp expect actual
471
+'
472
+
473
cat >expect <<\EOF
474
Author: Santa Claus <santa.claus@northpole.xx>
475
Author: Santa Claus <santa.claus@northpole.xx>
@@ -461,6 +489,11 @@ test_expect_success 'Grep author with log.mailmap' '
489
test_cmp expect actual
490
'
491
492
+test_expect_success 'log.mailmap is true by default these days' '
493
+ git log --author Santa | grep Author >actual &&
494
+ test_cmp expect actual
495
+'
496
+
497
test_expect_success 'Only grep replaced author with --use-mailmap' '
498
git log --use-mailmap --author "<cto@coompany.xx>" >actual &&
499
test_must_be_empty actual