From: Matthias Lederhofer <matled@gmx.net>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: [PATCH] pager: use an environment variable for pager_in_use
Date: Fri, 16 Feb 2007 19:22:31 +0100 [thread overview]
Message-ID: <20070216182231.GA31676@moooo.ath.cx> (raw)
In-Reply-To: <20070216155658.GB7183@coredump.intra.peff.net>
When running a shell script the value of pager_in_use is
lost for later processes. Therefore pager_in_use is
replaced by the environment variable GIT_PAGER_IN_USE.
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
Jeff King <peff@peff.net> wrote:
> Your analysis looks right to me. I think you would need to set
> GIT_PAGER_IN_USE in the environment whenever you turn on the pager in
> the git wrapper, and then set git's internal pager_in_use variable based
> on that.
This patch replaces pager_in_use because pager_in_use was only used at
two places (one sets it, the other reads it).
---
cache.h | 1 -
color.c | 2 +-
environment.c | 1 -
| 3 ++-
4 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/cache.h b/cache.h
index c62b0b0..aeaac9f 100644
--- a/cache.h
+++ b/cache.h
@@ -445,7 +445,6 @@ extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char
/* pager.c */
extern void setup_pager(void);
-extern int pager_in_use;
extern int pager_use_color;
/* base85 */
diff --git a/color.c b/color.c
index 09d82ee..50e073a 100644
--- a/color.c
+++ b/color.c
@@ -121,7 +121,7 @@ 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)) {
+ if (isatty(1) || (getenv("GIT_PAGER_IN_USE") && pager_use_color)) {
char *term = getenv("TERM");
if (term && strcmp(term, "dumb"))
return 1;
diff --git a/environment.c b/environment.c
index 54c22f8..5b477c3 100644
--- a/environment.c
+++ b/environment.c
@@ -26,7 +26,6 @@ const char *apply_default_whitespace;
int zlib_compression_level = Z_DEFAULT_COMPRESSION;
size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
-int pager_in_use;
int pager_use_color = 1;
static const char *git_dir;
--git a/pager.c b/pager.c
index 5f280ab..f59c94f 100644
--- a/pager.c
+++ b/pager.c
@@ -38,7 +38,8 @@ void setup_pager(void)
else if (!*pager || !strcmp(pager, "cat"))
return;
- pager_in_use = 1; /* means we are emitting to terminal */
+ /* means we are emitting to terminal */
+ setenv("GIT_PAGER_IN_USE", "1", 0);
if (pipe(fd) < 0)
return;
--
1.5.0
next prev parent reply other threads:[~2007-02-16 18:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-16 15:19 [BUG] git -p status does not use colors Matthias Lederhofer
2007-02-16 15:56 ` Jeff King
2007-02-16 18:22 ` Matthias Lederhofer [this message]
2007-02-16 18:35 ` [PATCH] pager: use an environment variable for pager_in_use Johannes Schindelin
2007-02-16 18:56 ` Matthias Lederhofer
2007-02-16 19:06 ` Johannes Schindelin
2007-02-16 19:43 ` Simon 'corecode' Schubert
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=20070216182231.GA31676@moooo.ath.cx \
--to=matled@gmx.net \
--cc=git@vger.kernel.org \
--cc=peff@peff.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).