log: add log.mailmap configuration option
Teach "log.mailmap" configuration variable to turn "--use-mailmap" option on to "git log", "git show" and "git whatchanged". The "--no-use-mailmap" option from the command line can countermand the setting. Signed-off-by: Antoine Pelisse <apelisse@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Antoine Pelisse committed
Jan 5, 2013 at 22:26 UTC
e6bb5f78fb351c89a80826befda3c8f06f91f249
3 files changed
+35
Documentation/config.txt
+4
@@ -1509,6 +1509,10 @@ log.showroot::
1509
Tools like linkgit:git-log[1] or linkgit:git-whatchanged[1], which
1510
normally hide the root commit will now show it. True by default.
1511
1512
+log.mailmap::
1513
+ If true, makes linkgit:git-log[1], linkgit:git-show[1], and
1514
+ linkgit:git-whatchanged[1] assume `--use-mailmap`.
1515
+
1516
mailmap.file::
1517
The location of an augmenting mailmap file. The default
1518
mailmap, located in the root of the repository, is loaded
builtin/log.c
+7
@@ -31,6 +31,7 @@ static int default_abbrev_commit;
31
static int default_show_root = 1;
32
static int decoration_style;
33
static int decoration_given;
34
+static int use_mailmap_config;
35
static const char *fmt_patch_subject_prefix = "PATCH";
36
static const char *fmt_pretty;
37
@@ -106,6 +107,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
107
OPT_END()
108
};
109
110
+ mailmap = use_mailmap_config;
111
argc = parse_options(argc, argv, prefix,
112
builtin_log_options, builtin_log_usage,
113
PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN |
@@ -358,6 +360,11 @@ static int git_log_config(const char *var, const char *value, void *cb)
360
}
361
if (!prefixcmp(var, "color.decorate."))
362
return parse_decorate_color_config(var, 15, value);
363
+ if (!strcmp(var, "log.mailmap")) {
364
+ use_mailmap_config = git_config_bool(var, value);
365
+ return 0;
366
+ }
367
+
368
if (grep_config(var, value, cb) < 0)
369
return -1;
370
return git_diff_ui_config(var, value, cb);
t/t4203-mailmap.sh
+24
@@ -254,6 +254,21 @@ test_expect_success 'Log output with --use-mailmap' '
254
test_cmp expect actual
255
'
256
257
+cat >expect <<\EOF
258
+Author: CTO <cto@company.xx>
259
+Author: Santa Claus <santa.claus@northpole.xx>
260
+Author: Santa Claus <santa.claus@northpole.xx>
261
+Author: Other Author <other@author.xx>
262
+Author: Other Author <other@author.xx>
263
+Author: Some Dude <some@dude.xx>
264
+Author: A U Thor <author@example.com>
265
+EOF
266
+
267
+test_expect_success 'Log output with log.mailmap' '
268
+ git -c log.mailmap=True log | grep Author >actual &&
269
+ test_cmp expect actual
270
+'
271
+
272
cat >expect <<\EOF
273
Author: Santa Claus <santa.claus@northpole.xx>
274
Author: Santa Claus <santa.claus@northpole.xx>
@@ -263,6 +278,15 @@ test_expect_success 'Grep author with --use-mailmap' '
278
git log --use-mailmap --author Santa | grep Author >actual &&
279
test_cmp expect actual
280
'
281
+cat >expect <<\EOF
282
+Author: Santa Claus <santa.claus@northpole.xx>
283
+Author: Santa Claus <santa.claus@northpole.xx>
284
+EOF
285
+
286
+test_expect_success 'Grep author with log.mailmap' '
287
+ git -c log.mailmap=True log --author Santa | grep Author >actual &&
288
+ test_cmp expect actual
289
+'
290
291
>expect
292