Skip to content

Commit f3eda90

Browse files
committed
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7ed20f5 commit f3eda90

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

Documentation/config/log.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ log.showSignature::
4141
log.mailmap::
4242
If true, makes linkgit:git-log[1], linkgit:git-show[1], and
4343
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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static int default_follow;
4747
static int default_show_signature;
4848
static int decoration_style;
4949
static int decoration_given;
50-
static int use_mailmap_config = -1;
50+
static int use_mailmap_config = 1;
5151
static const char *fmt_patch_subject_prefix = "PATCH";
5252
static const char *fmt_pretty;
5353

@@ -160,7 +160,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
160160
struct rev_info *rev, struct setup_revision_opt *opt)
161161
{
162162
struct userformat_want w;
163-
int quiet = 0, source = 0, mailmap = 0;
163+
int quiet = 0, source = 0, mailmap;
164164
static struct line_opt_callback_data line_cb = {NULL, NULL, STRING_LIST_INIT_DUP};
165165
static struct string_list decorate_refs_exclude = STRING_LIST_INIT_NODUP;
166166
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,
204204
memset(&w, 0, sizeof(w));
205205
userformat_find_requirements(NULL, &w);
206206

207-
if (mailmap < 0)
208-
mailmap = 0;
209-
210207
if (!rev->show_notes_given && (!rev->pretty_given || w.notes))
211208
rev->show_notes = 1;
212209
if (rev->show_notes)

t/t4203-mailmap.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,34 @@ test_expect_success 'Log output with log.mailmap' '
442442
test_cmp expect actual
443443
'
444444

445+
test_expect_success 'log.mailmap=false disables mailmap' '
446+
cat >expect <<-\EOF &&
447+
Author: CTO <[email protected]>
448+
Author: claus <[email protected]>
449+
Author: santa <[email protected]>
450+
Author: nick2 <[email protected]>
451+
Author: nick2 <[email protected]>
452+
Author: nick1 <[email protected]>
453+
Author: A U Thor <[email protected]>
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 <[email protected]>
462+
Author: claus <[email protected]>
463+
Author: santa <[email protected]>
464+
Author: nick2 <[email protected]>
465+
Author: nick2 <[email protected]>
466+
Author: nick1 <[email protected]>
467+
Author: A U Thor <[email protected]>
468+
EOF
469+
git log --no-use-mailmap | grep Author > actual &&
470+
test_cmp expect actual
471+
'
472+
445473
cat >expect <<\EOF
446474
Author: Santa Claus <[email protected]>
447475
Author: Santa Claus <[email protected]>
@@ -461,6 +489,11 @@ test_expect_success 'Grep author with log.mailmap' '
461489
test_cmp expect actual
462490
'
463491

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+
464497
test_expect_success 'Only grep replaced author with --use-mailmap' '
465498
git log --use-mailmap --author "<[email protected]>" >actual &&
466499
test_must_be_empty actual

0 commit comments

Comments
 (0)