git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: git@vger.kernel.org, gitster@pobox.com
Cc: Stefano Lattarini <stefano.lattarini@gmail.com>,
	Johan Herland <johan@herland.net>,
	Felipe Contreras <felipe.contreras@gmail.com>,
	Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: [PATCH 1/2] config: refactor management of color.ui's default value
Date: Wed, 15 May 2013 19:00:55 +0200	[thread overview]
Message-ID: <1368637256-22622-1-git-send-email-Matthieu.Moy@imag.fr> (raw)
In-Reply-To: <vpq61ykfang.fsf@grenoble-inp.fr>

The meaning of get_colorbool_found and get_diff_color_found is "the
config value if found, and -1 otherwise", but get_color_ui_found had a
slightly different meaning, as it has the value 0 (which corresponds to
the default value from the user point of view) when color.ui is unset.

Make get_color_ui_found default to -1, and make it explicit that 0 is the
default value when nothing else is found.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
So, this is new, as suggested by Junio.

 builtin/config.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/builtin/config.c b/builtin/config.c
index 000d27c..171bad7 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -333,6 +333,7 @@ static int get_colorbool(int print)
 {
 	get_colorbool_found = -1;
 	get_diff_color_found = -1;
+	get_color_ui_found = -1;
 	git_config_with_options(git_get_colorbool_config, NULL,
 				given_config_file, given_config_blob,
 				respect_includes);
@@ -344,6 +345,10 @@ static int get_colorbool(int print)
 			get_colorbool_found = get_color_ui_found;
 	}
 
+	if (get_colorbool_found < 0)
+		/* default value if none found in config */
+		get_colorbool_found = 0;
+
 	get_colorbool_found = want_color(get_colorbool_found);
 
 	if (print) {
-- 
1.8.3.rc1.315.g4602f33

  reply	other threads:[~2013-05-15 17:02 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-15  6:23 is this a bug of git-diff? eric liou
2013-05-15  6:43 ` Antoine Pelisse
     [not found]   ` <CABwUO_Wyq34S=CwbLeAqmzaFLxORkvGEvrjUzMXjkJdE1jnbhA@mail.gmail.com>
2013-05-15  7:10     ` Antoine Pelisse
2013-05-15  9:34       ` Matthieu Moy
2013-05-15  9:50         ` John Keeping
2013-05-15 10:03           ` Default for color.ui (was Re: is this a bug of git-diff?) Matthieu Moy
2013-05-15 10:37             ` Felipe Contreras
2013-05-15 12:09             ` [PATCH] make color.ui default to 'auto' Matthieu Moy
2013-05-15 12:59               ` Johan Herland
2013-05-15 13:21                 ` [PATCH v2] " Matthieu Moy
2013-05-15 16:09                   ` Junio C Hamano
2013-05-15 16:52                     ` Matthieu Moy
2013-05-15 17:00                       ` Matthieu Moy [this message]
2013-05-15 17:00                         ` [PATCH 2/2 v4] " Matthieu Moy
2013-05-15 17:30                       ` [PATCH v2] " Junio C Hamano
2013-05-15 13:20               ` [PATCH] " Stefano Lattarini
2013-05-15 14:24                 ` [PATCH v3] " Matthieu Moy
2013-05-15 15:42               ` [PATCH] " Junio C Hamano
2013-05-15 16:27                 ` Matthieu Moy
2013-05-15 17:34                   ` Junio C Hamano
2013-05-15 17:56                     ` Matthieu Moy
2013-05-15 18:08                       ` Junio C Hamano
2013-05-15 18:21                         ` Matthieu Moy
2013-05-15 18:32                           ` Junio C Hamano
2013-05-15 19:41                             ` Felipe Contreras
2013-05-15 16:43                 ` John Keeping
2013-05-15 10:31           ` is this a bug of git-diff? Mike Hommey
  -- strict thread matches above, loose matches on Subject: below --
2013-06-10 14:26 [PATCH 1/2] config: refactor management of color.ui's default value Matthieu Moy
2013-06-10 20:50 ` Junio C Hamano

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=1368637256-22622-1-git-send-email-Matthieu.Moy@imag.fr \
    --to=matthieu.moy@imag.fr \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johan@herland.net \
    --cc=stefano.lattarini@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).