X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=pager.c;h=5f280ab52720772905cacbcba522ecc9c81bb529;hb=ed35dece2776b0b83d7a35c84ab961668ec11ef4;hp=bb14e99735dd08c31c66325eacdcde4f3f2c685c;hpb=85fb65ed6e41e93760a91b33b512d3d9dc67ac66;p=git.git diff --git a/pager.c b/pager.c index bb14e9973..5f280ab52 100644 --- a/pager.c +++ b/pager.c @@ -1,14 +1,24 @@ #include "cache.h" +#include + /* * This is split up from the rest of git so that we might do * something different on Windows, for example. */ -int pager_in_use; - static void run_pager(const char *pager) { + /* + * Work around bug in "less" by not starting it until we + * have real input + */ + fd_set in; + + FD_ZERO(&in); + FD_SET(0, &in); + select(1, &in, NULL, &in, NULL); + execlp(pager, pager, NULL); execl("/bin/sh", "sh", "-c", pager, NULL); } @@ -17,10 +27,12 @@ void setup_pager(void) { pid_t pid; int fd[2]; - const char *pager = getenv("PAGER"); + const char *pager = getenv("GIT_PAGER"); if (!isatty(1)) return; + if (!pager) + pager = getenv("PAGER"); if (!pager) pager = "less"; else if (!*pager || !strcmp(pager, "cat")) @@ -50,7 +62,7 @@ void setup_pager(void) close(fd[0]); close(fd[1]); - setenv("LESS", "-RS", 0); + setenv("LESS", "FRSX", 0); run_pager(pager); die("unable to execute pager '%s'", pager); exit(255);