From: Michel Marti <mma@objectxp.com>
To: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH] git-diff: don't use colors when stdout is not a tty.
Date: Fri, 06 Jul 2007 17:35:10 +0200 [thread overview]
Message-ID: <468E612E.2070903@objectxp.com> (raw)
Currently, with diff-coloring enabled, git-diff outputs color escape
sequences even if stdout is redirected (not a tty). This is rather annoying
when trying to further process the output. This patch teaches the diff command
to only do its coloring stuff when a pager is in use or stdout is a tty.
Signed-off-by: Michel Marti <mma@objectxp.com>
---
diff.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/diff.c b/diff.c
index 1958970..988e741 100644
--- a/diff.c
+++ b/diff.c
@@ -451,7 +451,7 @@ static void free_diff_words_data(struct emit_callback *ecbdata)
const char *diff_get_color(int diff_use_color, enum color_diff ix)
{
- if (diff_use_color)
+ if (diff_use_color && (pager_in_use || isatty(STDOUT_FILENO)))
return diff_colors[ix];
return "";
}
--
1.5.2.2
next reply other threads:[~2007-07-06 16:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-06 15:35 Michel Marti [this message]
2007-07-06 16:37 ` [PATCH] git-diff: don't use colors when stdout is not a tty Matthias Lederhofer
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=468E612E.2070903@objectxp.com \
--to=mma@objectxp.com \
--cc=git@vger.kernel.org \
/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).