git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Lederhofer <matled@gmx.net>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] git-status: colorize status output
Date: Sat, 5 Aug 2006 14:18:21 +0200	[thread overview]
Message-ID: <20060805121821.GB20807@moooo.ath.cx> (raw)
In-Reply-To: <7v64h7e7dm.fsf@assigned-by-dhcp.cox.net>

Junio C Hamano <junkio@cox.net> wrote:
> Matthias Lederhofer <matled@gmx.net> writes:
> Arrrrrrrgh!  The message I wanted to send you went to Jeff.
> 
> Your Mail-Followup-To: fooled me.  Please do not do this.
Sorry.

> > Is there any reason not checking isatty()?
> 
> Not that I can think of, but do people really run "git status"?
I do :)

> I think Jeff's follow-up "vim colorizer" makes a lot more sense
> than colorizing "git status" output -- it gives reminder during
> the last chance the user has to notice such problems, which is
> while composing the commit log message.
I like the colored git status.  Here is a patch to honor isatty(1) and
pager_in_use (exporting GIT_PAGER_IN_USE) with pager.color.

---
From c01b26cd332283d3b3feaeae4a8218bb409aea2c Mon Sep 17 00:00:00 2001
From: Matthias Lederhofer <matled@gmx.net>
Date: Sat, 5 Aug 2006 14:09:49 +0200
Subject: [PATCH] git-status: do not use colors all the time

Either [ -t 1 ] has to be true or the pager is used and pager.color is
not false.

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
 git-commit.sh |    6 +++++-
 pager.c       |    1 +
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/git-commit.sh b/git-commit.sh
index b7269c2..ad0cbb1 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -20,7 +20,11 @@ case "$0" in
 *status)
 	status_only=t
 	unmerged_ok_if_status=--unmerged
-	color=`git-repo-config --bool --get status.color`
+	[ "`git-repo-config --bool --get status.color`" = 'true' ] &&
+		([ -t 1 ] || (
+			[ -n "$GIT_PAGER_IN_USE" ] &&
+			[ "`git-repo-config --bool --get pager.color`" != 'false' ]
+		)) && color=true
 	eval `git-repo-config --get-regexp status.color. \
 	      | while read k v; do
 	          echo color_${k#status.color.}=$v
diff --git a/pager.c b/pager.c
index dcb398d..3ba4166 100644
--- a/pager.c
+++ b/pager.c
@@ -27,6 +27,7 @@ void setup_pager(void)
 		return;
 
 	pager_in_use = 1; /* means we are emitting to terminal */
+	setenv("GIT_PAGER_IN_USE", "1", 1);
 
 	if (pipe(fd) < 0)
 		return;
-- 
1.4.2.rc2.gd71a

  reply	other threads:[~2006-08-05 12:18 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-05  3:14 [PATCH] git-status: colorize status output Jeff King
2006-08-05  3:21 ` Jeff King
2006-08-05  8:16   ` Greg KH
2006-08-05  9:28 ` Junio C Hamano
2006-08-05 10:21   ` Jeff King
2006-08-05 10:44     ` Jeff King
2006-08-05 10:59 ` Matthias Lederhofer
2006-08-05 11:21   ` Junio C Hamano
2006-08-05 11:27     ` Junio C Hamano
2006-08-05 11:28     ` Matthias Lederhofer
2006-08-05 11:42       ` Junio C Hamano
2006-08-05 12:18         ` Matthias Lederhofer [this message]
2006-08-05 19:54           ` Jeff King
2006-08-05 20:31             ` Matthias Lederhofer
2006-08-05 19:51         ` Jeff King
2006-08-07 17:12         ` Sam Ravnborg
2006-08-05 19:45   ` Jeff King
2006-08-05 20:27     ` Matthias Lederhofer
2006-08-05 23:42       ` Jeff King
2006-08-06  5:01 ` Joel Becker
2006-08-06  6:16   ` Jeff King

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=20060805121821.GB20807@moooo.ath.cx \
    --to=matled@gmx.net \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.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).