Skip to content

Commit c7cf2de

Browse files
committed
Merge branch 'ac/log-use-mailmap-by-default-transition'
The "git log" command learns to issue a warning when log.mailmap configuration is not set and --[no-]mailmap option is not used, to prepare users for future versions of Git that uses the mailmap by default. * ac/log-use-mailmap-by-default-transition: tests: defang pager tests by explicitly disabling the log.mailmap warning documentation: mention --no-use-mailmap and log.mailmap false setting log: add warning for unspecified log.mailmap setting
2 parents f87ee7f + ef60740 commit c7cf2de

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

Documentation/config/log.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ log.showSignature::
4040

4141
log.mailmap::
4242
If true, makes linkgit:git-log[1], linkgit:git-show[1], and
43-
linkgit:git-whatchanged[1] assume `--use-mailmap`.
43+
linkgit:git-whatchanged[1] assume `--use-mailmap`, otherwise
44+
assume `--no-use-mailmap`. False by default.

Documentation/git-log.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ OPTIONS
4949
Print out the ref name given on the command line by which each
5050
commit was reached.
5151

52-
--use-mailmap::
52+
--[no-]use-mailmap::
5353
Use mailmap file to map author and committer names and email
5454
addresses to canonical real names and email addresses. See
5555
linkgit:git-shortlog[1].

builtin/log.c

Lines changed: 24 additions & 2 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;
50+
static int use_mailmap_config = -1;
5151
static const char *fmt_patch_subject_prefix = "PATCH";
5252
static const char *fmt_pretty;
5353

@@ -63,9 +63,14 @@ struct line_opt_callback_data {
6363
struct string_list args;
6464
};
6565

66+
static int session_is_interactive(void)
67+
{
68+
return isatty(1) || pager_in_use();
69+
}
70+
6671
static int auto_decoration_style(void)
6772
{
68-
return (isatty(1) || pager_in_use()) ? DECORATE_SHORT_REFS : 0;
73+
return session_is_interactive() ? DECORATE_SHORT_REFS : 0;
6974
}
7075

7176
static int parse_decoration_style(const char *value)
@@ -151,6 +156,16 @@ static void cmd_log_init_defaults(struct rev_info *rev)
151156
parse_date_format(default_date_mode, &rev->date_mode);
152157
}
153158

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+
154169
static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
155170
struct rev_info *rev, struct setup_revision_opt *opt)
156171
{
@@ -199,6 +214,13 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
199214
memset(&w, 0, sizeof(w));
200215
userformat_find_requirements(NULL, &w);
201216

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+
202224
if (!rev->show_notes_given && (!rev->pretty_given || w.notes))
203225
rev->show_notes = 1;
204226
if (rev->show_notes)

t/t7006-pager.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ 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 &&
1012
sane_unset GIT_PAGER GIT_PAGER_IN_USE &&
1113
test_unconfig core.pager &&
1214

0 commit comments

Comments
 (0)