path: root/pager.c
diff options
authorJonathan Nieder <>2010-02-14 11:59:59 (GMT)
committerJunio C Hamano <>2010-02-15 02:23:17 (GMT)
commit64778d24a93ad455e5883120aef350ede20061c4 (patch)
tree259b89f31782ad41f40b6e7d51f054adbefae9e8 /pager.c
parent9fabb6d7513ab0a264de146d72a8447bc85b5e85 (diff)
Make 'git var GIT_PAGER' always print the configured pager
Scripted commands that want to use git’s configured pager know better than ‘git var’ does whether stdout is going to be a tty at the appropriate time. Checking isatty(1) as git_pager() does now won’t cut it, since the output of git var itself is almost never a terminal. The symptom is that when used by humans, ‘git var GIT_PAGER’ behaves as it should, but when used by scripts, it always returns ‘cat’! So avoid tricks with isatty() and just always print the configured pager. This does not fix the callers to check isatty(1) themselves yet. Nevertheless, this patch alone is enough to fix 'am --interactive'. Thanks to Sebastian Celis for the report and Jeff King for the analysis. Reported-by: Sebastian Celis <> Signed-off-by: Jonathan Nieder <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'pager.c')
1 files changed, 3 insertions, 3 deletions
diff --git a/pager.c b/pager.c
index 2c7e8ec..dac358f 100644
--- a/pager.c
+++ b/pager.c
@@ -48,11 +48,11 @@ static void wait_for_pager_signal(int signo)
-const char *git_pager(void)
+const char *git_pager(int stdout_is_tty)
const char *pager;
- if (!isatty(1))
+ if (!stdout_is_tty)
return NULL;
pager = getenv("GIT_PAGER");
@@ -73,7 +73,7 @@ const char *git_pager(void)
void setup_pager(void)
- const char *pager = git_pager();
+ const char *pager = git_pager(isatty(1));
if (!pager)