From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Eric Wong <normalperson@yhbt.net>, git@vger.kernel.org
Subject: Re: [PATCH 2/3] git config --get-colorbool
Date: Wed, 05 Dec 2007 22:12:07 -0800 [thread overview]
Message-ID: <7vve7cgxmw.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20071206053059.GF5499@coredump.intra.peff.net> (Jeff King's message of "Thu, 6 Dec 2007 00:30:59 -0500")
Jeff King <peff@peff.net> writes:
> [Eric Wong cc'd because of git-svn relevance]
>
> On Wed, Dec 05, 2007 at 06:05:04PM -0800, Junio C Hamano wrote:
>
>> This adds an option to help scripts find out color settings from
>> the configuration file.
>>
>> git config --get-colorbool color.diff
>>
>> inspects color.diff variable, and exits with status 0 (i.e. success) if
>> color is to be used. It exits with status 1 otherwise.
>
> There is no way to differentiate between "do not use color" and "no
> value found". This makes it impossible to use this to implement the
> required "try color.diff, fallback to diff.color" behavior.
>
> We could simply make it
>
> git config --get-colorbool diff
>
> which would check both (and when diff.color support is finally dropped,
> just remove it from there).
I thought about this a bit and thought that it would probably be a good
workaround to teach "--get-colorbool that diff.color is a deprecated
synonym to color.diff, like this.
-- >8 --
config --get-colorbool: diff.color is a deprecated synonym to color.diff
The applications can ask for color.diff but the configuration of old
timer users can still instruct it to use color with diff.color this
way.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin-config.c | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/builtin-config.c b/builtin-config.c
index d10b03f..e4a12e3 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -210,11 +210,17 @@ static int get_color(int argc, const char **argv)
static int stdout_is_tty;
static int get_colorbool_found;
+static int get_diff_color_found;
static int git_get_colorbool_config(const char *var, const char *value)
{
- if (!strcmp(var, get_color_slot))
+ if (!strcmp(var, get_color_slot)) {
get_colorbool_found =
git_config_colorbool(var, value, stdout_is_tty);
+ }
+ if (!strcmp(var, "diff.color")) {
+ get_diff_color_found =
+ git_config_colorbool(var, value, stdout_is_tty);
+ }
return 0;
}
@@ -233,10 +239,18 @@ static int get_colorbool(int argc, const char **argv)
stdout_is_tty = isatty(1);
else
usage(git_config_set_usage);
- get_colorbool_found = 0;
+ get_colorbool_found = -1;
+ get_diff_color_found = -1;
get_color_slot = argv[0];
git_config(git_get_colorbool_config);
+ if (get_colorbool_found < 0) {
+ if (!strcmp(get_color_slot, "color.diff"))
+ get_colorbool_found = get_diff_color_found;
+ if (get_colorbool_found < 0)
+ get_colorbool_found = 0;
+ }
+
if (argc == 1) {
return get_colorbool_found ? 0 : 1;
} else {
next prev parent reply other threads:[~2007-12-06 6:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-05 10:59 [PATCH] Color support for "git-add -i" Junio C Hamano
2007-12-05 12:21 ` Johannes Sixt
2007-12-05 13:52 ` Wincent Colaiuta
2007-12-05 19:46 ` Junio C Hamano
2007-12-06 2:05 ` [PATCH 1/3] Documentation: color.* = true means "auto" Junio C Hamano
2007-12-06 2:05 ` [PATCH 2/3] git config --get-colorbool Junio C Hamano
2007-12-06 2:05 ` [PATCH 3/3] Color support for "git-add -i" Junio C Hamano
2007-12-06 2:05 ` [PATCH 0/3] Reroll colorized "git add -i" Junio C Hamano
2007-12-06 5:40 ` [PATCH 3/3] Color support for "git-add -i" Jeff King
2007-12-06 19:59 ` Wincent Colaiuta
2007-12-06 20:18 ` Junio C Hamano
2007-12-07 12:34 ` Wincent Colaiuta
2007-12-06 5:30 ` [PATCH 2/3] git config --get-colorbool Jeff King
2007-12-06 5:35 ` Jeff King
2007-12-06 6:12 ` Junio C Hamano [this message]
2007-12-06 6:17 ` Jeff King
2007-12-06 7:38 ` Eric Wong
2007-12-05 13:55 ` [PATCH] Color support for "git-add -i" Wincent Colaiuta
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vve7cgxmw.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=normalperson@yhbt.net \
--cc=peff@peff.net \
/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.
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 NNTP newsgroup(s).