Skip to content

Commit 9b274e2

Browse files
committed
Merge branch 'jc/log-mailmap-flip-defaults'
Hotfix for making "git log" use the mailmap by default. * jc/log-mailmap-flip-defaults: log: really flip the --mailmap default log: flip the --mailmap default unconditionally
2 parents e46249f + f3eda90 commit 9b274e2

File tree

5 files changed

+39
-27
lines changed

5 files changed

+39
-27
lines changed

Documentation/RelNotes/2.23.0.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Backward compatibility note
1010
prerequisite patches in an unstable way, which has been updated to
1111
compute in a way that is compatible with "git patch-id --stable".
1212

13+
* The "git log" command by default behaves as if the --mailmap option
14+
was given.
15+
1316

1417
UI, Workflows & Features
1518

@@ -91,11 +94,6 @@ UI, Workflows & Features
9194
commit-graph files now, which allows the commit-graph files to be
9295
updated incrementally.
9396

94-
* The "git log" command learns to issue a warning when log.mailmap
95-
configuration is not set and --[no-]mailmap option is not used, to
96-
prepare users for future versions of Git that uses the mailmap by
97-
default.
98-
9997
* "git range-diff" output has been tweaked for easier identification
10098
of which part of what file the patch shown is about.
10199

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 & 19 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

@@ -156,21 +156,11 @@ static void cmd_log_init_defaults(struct rev_info *rev)
156156
parse_date_format(default_date_mode, &rev->date_mode);
157157
}
158158

159-
static char warn_unspecified_mailmap_msg[] =
160-
N_("log.mailmap is not set; its implicit value will change in an\n"
161-
"upcoming release. To squelch this message and preserve current\n"
162-
"behaviour, set the log.mailmap configuration value to false.\n"
163-
"\n"
164-
"To squelch this message and adopt the new behaviour now, set the\n"
165-
"log.mailmap configuration value to true.\n"
166-
"\n"
167-
"See 'git help config' and search for 'log.mailmap' for further information.");
168-
169159
static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
170160
struct rev_info *rev, struct setup_revision_opt *opt)
171161
{
172162
struct userformat_want w;
173-
int quiet = 0, source = 0, mailmap = 0;
163+
int quiet = 0, source = 0, mailmap;
174164
static struct line_opt_callback_data line_cb = {NULL, NULL, STRING_LIST_INIT_DUP};
175165
static struct string_list decorate_refs_exclude = STRING_LIST_INIT_NODUP;
176166
static struct string_list decorate_refs_include = STRING_LIST_INIT_NODUP;
@@ -214,13 +204,6 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
214204
memset(&w, 0, sizeof(w));
215205
userformat_find_requirements(NULL, &w);
216206

217-
if (mailmap < 0) {
218-
if (session_is_interactive() && !rev->pretty_given)
219-
warning("%s\n", _(warn_unspecified_mailmap_msg));
220-
221-
mailmap = 0;
222-
}
223-
224207
if (!rev->show_notes_given && (!rev->pretty_given || w.notes))
225208
rev->show_notes = 1;
226209
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

t/t7006-pager.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ test_description='Test automatic use of a pager.'
77
. "$TEST_DIRECTORY"/lib-terminal.sh
88

99
test_expect_success 'setup' '
10-
: squelch advice messages during the transition &&
11-
git config --global log.mailmap false &&
1210
sane_unset GIT_PAGER GIT_PAGER_IN_USE &&
1311
test_unconfig core.pager &&
1412

0 commit comments

Comments
 (0)