* [BUG] git -p status does not use colors @ 2007-02-16 15:19 Matthias Lederhofer 2007-02-16 15:56 ` Jeff King 0 siblings, 1 reply; 7+ messages in thread From: Matthias Lederhofer @ 2007-02-16 15:19 UTC (permalink / raw) To: git git -p status starts the pager, then runs git-commit.sh (named git-status) which in turn runs git-runstatus. I guess the problem is that git-runstatus cannot check that the pager was started and just knows that stdout is no terminal. Has anyone an idea how to fix this? ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [BUG] git -p status does not use colors 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 ` [PATCH] pager: use an environment variable for pager_in_use Matthias Lederhofer 0 siblings, 1 reply; 7+ messages in thread From: Jeff King @ 2007-02-16 15:56 UTC (permalink / raw) To: git On Fri, Feb 16, 2007 at 04:19:25PM +0100, Matthias Lederhofer wrote: > git -p status starts the pager, then runs git-commit.sh (named > git-status) which in turn runs git-runstatus. I guess the problem is > that git-runstatus cannot check that the pager was started and just > knows that stdout is no terminal. Has anyone an idea how to fix > this? 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. -Peff ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] pager: use an environment variable for pager_in_use 2007-02-16 15:56 ` Jeff King @ 2007-02-16 18:22 ` Matthias Lederhofer 2007-02-16 18:35 ` Johannes Schindelin 0 siblings, 1 reply; 7+ messages in thread From: Matthias Lederhofer @ 2007-02-16 18:22 UTC (permalink / raw) To: Jeff King; +Cc: git 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 - pager.c | 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; diff --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 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] pager: use an environment variable for pager_in_use 2007-02-16 18:22 ` [PATCH] pager: use an environment variable for pager_in_use Matthias Lederhofer @ 2007-02-16 18:35 ` Johannes Schindelin 2007-02-16 18:56 ` Matthias Lederhofer 0 siblings, 1 reply; 7+ messages in thread From: Johannes Schindelin @ 2007-02-16 18:35 UTC (permalink / raw) To: Matthias Lederhofer; +Cc: Jeff King, git Hi, On Fri, 16 Feb 2007, Matthias Lederhofer wrote: > 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. Am I the only one who finds it ugly to set an environment variable for use in the same program? > -int pager_in_use; How about +int pager_in_use = getenv("GIT_PAGER_IN_USE"); ??? Ciao, Dscho ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] pager: use an environment variable for pager_in_use 2007-02-16 18:35 ` Johannes Schindelin @ 2007-02-16 18:56 ` Matthias Lederhofer 2007-02-16 19:06 ` Johannes Schindelin 0 siblings, 1 reply; 7+ messages in thread From: Matthias Lederhofer @ 2007-02-16 18:56 UTC (permalink / raw) To: Johannes Schindelin; +Cc: git Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote: > +int pager_in_use = getenv("GIT_PAGER_IN_USE"); test.c:3: error: initializer element is not constant So you could only add this at another place where pager_in_use is not yet used (e.g. start of main or some other initialization method). I did not want to put it at the beginning of main or another function. After adding GIT_PAGER_IN_USE I thought it would make sense to remove pager_in_use because there were only two parts of code using pager_in_use: > pager_in_use = 1; > setenv(..); and > pager_in_use || getenv(..) ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] pager: use an environment variable for pager_in_use 2007-02-16 18:56 ` Matthias Lederhofer @ 2007-02-16 19:06 ` Johannes Schindelin 2007-02-16 19:43 ` Simon 'corecode' Schubert 0 siblings, 1 reply; 7+ messages in thread From: Johannes Schindelin @ 2007-02-16 19:06 UTC (permalink / raw) To: Matthias Lederhofer; +Cc: git Hi, On Fri, 16 Feb 2007, Matthias Lederhofer wrote: > Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote: > > +int pager_in_use = getenv("GIT_PAGER_IN_USE"); > test.c:3: error: initializer element is not constant Sorry. Still, it feels wrong to use two system calls when you need none. How about working on making status and commit a builtin instead? This would not only solve your issue, but portability issues as well. Ciao, Dscho ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] pager: use an environment variable for pager_in_use 2007-02-16 19:06 ` Johannes Schindelin @ 2007-02-16 19:43 ` Simon 'corecode' Schubert 0 siblings, 0 replies; 7+ messages in thread From: Simon 'corecode' Schubert @ 2007-02-16 19:43 UTC (permalink / raw) To: Johannes Schindelin; +Cc: Matthias Lederhofer, git [-- Attachment #1: Type: text/plain, Size: 840 bytes --] Johannes Schindelin wrote: >> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote: >>> +int pager_in_use = getenv("GIT_PAGER_IN_USE"); >> test.c:3: error: initializer element is not constant > Sorry. > > Still, it feels wrong to use two system calls when you need none. getenv() is usually no system call, but processed in userland. However, I also always get the feeling that using environment variables within one process to communicate state seems wrong, but many old unix tools do it this way. cheers simon -- Serve - BSD +++ RENT this banner advert +++ ASCII Ribbon /"\ Work - Mac +++ space for low €€€ NOW!1 +++ Campaign \ / Party Enjoy Relax | http://dragonflybsd.org Against HTML \ Dude 2c 2 the max ! http://golden-apple.biz Mail + News / \ [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 252 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-02-16 19:43 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 ` [PATCH] pager: use an environment variable for pager_in_use Matthias Lederhofer 2007-02-16 18:35 ` Johannes Schindelin 2007-02-16 18:56 ` Matthias Lederhofer 2007-02-16 19:06 ` Johannes Schindelin 2007-02-16 19:43 ` Simon 'corecode' Schubert
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.