From: Junio C Hamano <gitster@pobox.com>
To: Pascal Obry <pascal.obry@wanadoo.fr>
Cc: git list <git@vger.kernel.org>
Subject: Re: [PATCH] Use --no-color option on git log commands.
Date: Mon, 26 Nov 2007 14:30:28 -0800 [thread overview]
Message-ID: <7vr6icej23.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <474B42EC.1000408@wanadoo.fr> (Pascal Obry's message of "Mon, 26 Nov 2007 23:04:28 +0100")
Pascal Obry <pascal.obry@wanadoo.fr> writes:
> When colors are activated on the repository the git log output
> will contain control characters to set/reset the colors.
The patch is good as belt-and-suspender, thanks.
But I suspect that we should make 'true' to mean 'auto' someday in
git_config_colorbool(). Crazy people can set 'always' if they really
wanted to, but most normal people would not want color unless the output
goes to the terminal, I would think.
Something like this, perhaps...
---
color.c | 25 ++++++++++++-------------
1 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/color.c b/color.c
index 09d82ee..060d3cf 100644
--- a/color.c
+++ b/color.c
@@ -118,21 +118,24 @@ bad:
int git_config_colorbool(const char *var, const char *value)
{
- if (!value)
- return 1;
- if (!strcasecmp(value, "auto")) {
- if (isatty(1) || (pager_in_use && pager_use_color)) {
- char *term = getenv("TERM");
- if (term && strcmp(term, "dumb"))
- return 1;
- }
- return 0;
- }
- if (!strcasecmp(value, "never"))
- return 0;
- if (!strcasecmp(value, "always"))
- return 1;
- return git_config_bool(var, value);
+ if (value) {
+ if (!strcasecmp(value, "never"))
+ return 0;
+ if (!strcasecmp(value, "always"))
+ return 1;
+ if (!strcasecmp(value, "auto"))
+ goto auto;
+ }
+ if (!git_config_bool(var, value))
+ return 0;
+auto:
+ /* any normal truth value defaults to 'auto' */
+ if (isatty(1) || (pager_in_use && pager_use_color)) {
+ char *term = getenv("TERM");
+ if (term && strcmp(term, "dumb"))
+ return 1;
+ }
+ return 0;
}
static int color_vprintf(const char *color, const char *fmt,
next prev parent reply other threads:[~2007-11-26 22:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-26 22:04 [PATCH] Use --no-color option on git log commands Pascal Obry
2007-11-26 22:30 ` Junio C Hamano [this message]
2007-11-27 18:24 ` Pascal Obry
2007-11-28 4:45 ` Junio C Hamano
2007-11-28 7:26 ` [PATCH/RFC] "color.diff = true" is not "always" anymore Junio C Hamano
2007-11-28 13:13 ` Johannes Schindelin
2007-11-28 19:04 ` Jeff King
2007-12-01 2:36 ` Junio C Hamano
2007-12-01 4:15 ` Jeff King
2007-12-01 6:10 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vr6icej23.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=pascal.obry@wanadoo.fr \
/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).