git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: git@vger.kernel.org
Cc: Alex Henrie <alexhenrie24@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	Jonathan Nieder <jrnieder@gmail.com>
Subject: [PATCH v3] builtin/log: honor log.decorate
Date: Sun, 14 May 2017 18:00:58 +0000	[thread overview]
Message-ID: <20170514180058.842315-1-sandals@crustytoothpaste.net> (raw)
In-Reply-To: <20170512221221.406645-1-sandals@crustytoothpaste.net>

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>
---
Changes from v2:
* Add a test.  I tested that the config parsing both works with
  additional options and also can be overridden from the command line.

 builtin/log.c  |  4 ++--
 t/t4202-log.sh | 12 ++++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/builtin/log.c b/builtin/log.c
index b3b10cc1e..ec3258368 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -110,6 +110,8 @@ static void init_log_defaults(void)
 {
 	init_grep_defaults();
 	init_diff_ui_defaults();
+
+	decoration_style = auto_decoration_style();
 }
 
 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)
 		if (decoration_style < 0)
 			decoration_style = 0; /* maybe warn? */
 		return 0;
-	} else {
-		decoration_style = auto_decoration_style();
 	}
 	if (!strcmp(var, "log.showroot")) {
 		default_show_root = git_config_bool(var, value);
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index f57799071..1c7d6729c 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -577,6 +577,18 @@ test_expect_success 'log.decorate configuration' '
 
 '
 
+test_expect_success 'log.decorate config parsing' '
+	git log --oneline --decorate=full >expect.full &&
+	git log --oneline --decorate=short >expect.short &&
+
+	test_config log.decorate full &&
+	test_config log.mailmap true &&
+	git log --oneline >actual &&
+	test_cmp expect.full actual &&
+	git log --oneline --decorate=short >actual &&
+	test_cmp expect.short actual
+'
+
 test_expect_success TTY 'log output on a TTY' '
 	git log --oneline --decorate >expect.short &&
 

  parent reply	other threads:[~2017-05-14 18:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-12 21:34 [PATCH] builtin/log: honor log.decorate brian m. carlson
2017-05-12 22:03 ` Alex Henrie
2017-05-12 22:07   ` brian m. carlson
2017-05-12 22:12     ` [PATCH v2] " brian m. carlson
2017-05-12 22:22       ` Alex Henrie
2017-05-12 23:32       ` Jonathan Nieder
2017-05-12 23:37         ` brian m. carlson
2017-05-12 23:48           ` Jonathan Nieder
2017-05-13  1:23             ` Alex Henrie
2017-05-13  2:49               ` brian m. carlson
2017-05-13  2:41             ` brian m. carlson
2017-05-14 18:00       ` brian m. carlson [this message]
2017-05-15  2:35         ` [PATCH v3] " Junio C Hamano
2017-05-15  3:48           ` Alex Henrie
2017-05-15 16:26           ` Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170514180058.842315-1-sandals@crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=alexhenrie24@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).