* [PATCH] git-status: support always/auto/never in colorization
@ 2006-08-05 23:57 Jeff King
2006-08-06 0:38 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Jeff King @ 2006-08-05 23:57 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Signed-off-by: Jeff King <peff@peff.net>
---
This is on top of the previous two patches:
git-status: colorize status output (me)
git-status: do not use colors all the time (Matthias)
I was hoping to join the term selection logic with the diff.color logic
in git_config_termbool or similar (and a git-repo-config --termbool),
but unfortunately that doesn't work since git-repo-config can't do an
isatty test (since we call it as `git-repo-config`). In general, config
parsing is a little awkward (and inefficient) in sh. Is there any
interest in me converting git-commit/git-status to C builtins (I know
Johannes will be happy...)?
Documentation/config.txt | 4 +++-
git-commit.sh | 13 ++++++++-----
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 83f4627..43766bd 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -224,7 +224,9 @@ showbranch.default::
status.color::
A boolean to enable/disable color in the output of
- gitlink:git-status[1]. Defaults to false.
+ gitlink:git-status[1]. May be set to `true` (or `always`),
+ `false` (or `never`) or `auto`, in which case colors are used
+ only when the output is to a terminal. Defaults to false.
status.color.<slot>::
Use customized color for status colorization. `<slot>` is
diff --git a/git-commit.sh b/git-commit.sh
index ad0cbb1..2ab1974 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -20,11 +20,14 @@ case "$0" in
*status)
status_only=t
unmerged_ok_if_status=--unmerged
- [ "`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
+ case "`git-repo-config --get status.color`" in
+ always) color=true ;;
+ never ) color=false ;;
+ auto ) test -t 1 -o \( -n "$GIT_PAGER_IN_USE" -a \
+ "`git-repo-config --bool --get pager.color`" != false \) \
+ && color=true ;;
+ * ) color="`git-repo-config --bool --get status.color`" ;;
+ esac
eval `git-repo-config --get-regexp status.color. \
| while read k v; do
echo color_${k#status.color.}=$v
--
1.4.2.rc3.gf3bd-dirty
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] git-status: support always/auto/never in colorization
2006-08-05 23:57 [PATCH] git-status: support always/auto/never in colorization Jeff King
@ 2006-08-06 0:38 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2006-08-06 0:38 UTC (permalink / raw)
To: Jeff King; +Cc: git
Jeff King <peff@peff.net> writes:
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> This is on top of the previous two patches:
> git-status: colorize status output (me)
> git-status: do not use colors all the time (Matthias)
>
> I was hoping to join the term selection logic with the diff.color logic
> in git_config_termbool or similar (and a git-repo-config --termbool),
> but unfortunately that doesn't work since git-repo-config can't do an
> isatty test (since we call it as `git-repo-config`). In general, config
> parsing is a little awkward (and inefficient) in sh. Is there any
> interest in me converting git-commit/git-status to C builtins (I know
> Johannes will be happy...)?
I was planning to do only the status part in C anyway.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-08-06 0:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-05 23:57 [PATCH] git-status: support always/auto/never in colorization Jeff King
2006-08-06 0:38 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox