git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Kestenholz <mk@spinlock.ch>
To: gitster@pobox.com
Cc: git@vger.kernel.org, Matthias Kestenholz <mk@spinlock.ch>
Subject: [PATCH] Use color.ui variable in scripts too
Date: Wed,  9 Apr 2008 21:32:06 +0200	[thread overview]
Message-ID: <1207769526-14823-1-git-send-email-mk@spinlock.ch> (raw)

Signed-off-by: Matthias Kestenholz <mk@spinlock.ch>
---

	This patch adds color.ui support for scripts. It does that by
	modifying `git config --get-colorbool`, because there is no
	way to differentiate between undefined and `false` configuration
	variables in scripts. Additionally, the scripts don't need to be
	changed. I have only tested git add -i; git svn uses the same
	functions in Git.pm, so it should work too.

	Of course, it would have been nicer if I had made this change
	before the release of 1.5.5. The 1.5.5 announcement reminded
	me, that this had yet to be done.

 Documentation/git-config.txt |    2 ++
 builtin-config.c             |    6 +++++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index fa16171..5de5d05 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -144,6 +144,8 @@ See also <<FILES>>.
 	"auto".  If `stdout-is-tty` is missing, then checks the standard
 	output of the command itself, and exits with status 0 if color
 	is to be used, or exits with status 1 otherwise.
+	When the color setting for `name` is undefined, the command uses
+	`color.ui` as fallback.
 
 --get-color name default::
 
diff --git a/builtin-config.c b/builtin-config.c
index c34bc8b..eccb7e7 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -224,6 +224,10 @@ static int git_get_colorbool_config(const char *var, const char *value)
 		get_diff_color_found =
 			git_config_colorbool(var, value, stdout_is_tty);
 	}
+	if (!strcmp(var, "color.ui")) {
+		git_use_color_default = git_config_colorbool(var, value, stdout_is_tty);
+		return 0;
+	}
 	return 0;
 }
 
@@ -251,7 +255,7 @@ static int get_colorbool(int argc, const char **argv)
 		if (!strcmp(get_color_slot, "color.diff"))
 			get_colorbool_found = get_diff_color_found;
 		if (get_colorbool_found < 0)
-			get_colorbool_found = 0;
+			get_colorbool_found = git_use_color_default;
 	}
 
 	if (argc == 1) {
-- 
1.5.5.24.g0eec3.dirty

                 reply	other threads:[~2008-04-09 19:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1207769526-14823-1-git-send-email-mk@spinlock.ch \
    --to=mk@spinlock.ch \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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.
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).