builtin/log: honor log.decorate

The recent change that introduced autodecorating of refs accidentally broke the ability of users to set log.decorate = false to override it. When the git_log_config was traversed a second time with an option other than log.decorate, the decoration style would be set to the automatic style, even if the user had already overridden it. Instead of setting the option in config parsing, set it in init_log_defaults instead. Add a test for this case. The actual additional config option doesn't matter, but it needs to be something not already set in the configuration file. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Acked-by: Alex Henrie <alexhenrie24@gmail.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed May 14, 2017 at 18:00 UTC c74271aae74c951ab321aa16fe573ea3bcab86ba
2 files changed +14 -2
builtin/log.c
+2 -2
@@ -110,6 +110,8 @@ static void init_log_defaults(void)
110 {
111 init_grep_defaults();
112 init_diff_ui_defaults();
113 +
114 + decoration_style = auto_decoration_style();
115 }
116
117 static void cmd_log_init_defaults(struct rev_info *rev)
@@ -410,8 +412,6 @@ static int git_log_config(const char *var, const char *value, void *cb)
412 if (decoration_style < 0)
413 decoration_style = 0; /* maybe warn? */
414 return 0;
413 - } else {
414 - decoration_style = auto_decoration_style();
415 }
416 if (!strcmp(var, "log.showroot")) {
417 default_show_root = git_config_bool(var, value);
t/t4202-log.sh
+12
@@ -577,6 +577,18 @@ test_expect_success 'log.decorate configuration' '
577
578 '
579
580 +test_expect_success 'log.decorate config parsing' '
581 + git log --oneline --decorate=full >expect.full &&
582 + git log --oneline --decorate=short >expect.short &&
583 +
584 + test_config log.decorate full &&
585 + test_config log.mailmap true &&
586 + git log --oneline >actual &&
587 + test_cmp expect.full actual &&
588 + git log --oneline --decorate=short >actual &&
589 + test_cmp expect.short actual
590 +'
591 +
592 test_expect_success TTY 'log output on a TTY' '
593 git log --oneline --decorate >expect.short &&
594