summaryrefslogtreecommitdiff
path: root/pager.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2013-09-03 03:41:50 -0400
committerJunio C Hamano <gitster@pobox.com>2013-09-03 10:36:12 -0700
commited016612e6956496d5028e41f6414be29c09be4e (patch)
tree0ef7153a127500788f7b59ac0fd8d56358523063 /pager.c
parente230c568c4b9a991e3175e5f65171a566fd8e39c (diff)
downloadgit-ed016612e6956496d5028e41f6414be29c09be4e.tar.gz
pager: turn on "cat" optimization for DEFAULT_PAGERjk/pager-bypass-cat-for-default-pager
If the user specifies a pager of "cat" (or the empty string), whether it is in the environment or from config, we automagically optimize it out to mean "no pager" and avoid forking at all. We treat an empty pager variable similary. However, we did not apply this optimization when DEFAULT_PAGER was set to "cat" (or the empty string). There is no reason to treat DEFAULT_PAGER any differently. The optimization should not be user-visible (unless the user has a bizarre "cat" in their PATH). And even if it is, we are better off behaving consistently between the compile-time default and the environment and config settings. The stray "else" we are removing from this code was introduced by 402461a (pager: do not fork a pager if PAGER is set to empty., 2006-04-16). At that time, the line directly above used: if (!pager) pager = "less"; as a fallback, meaning that it could not possibly trigger the optimization. Later, a3d023d (Provide a build time default-pager setting, 2009-10-30) turned that constant into a build-time setting which could be anything, but didn't loosen the "else" to let DEFAULT_PAGER use the optimization. Noticed-by: Dale R. Worley <worley@alum.mit.edu> Suggested-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pager.c')
-rw-r--r--pager.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pager.c b/pager.c
index c1ecf657fd..fa19765eb9 100644
--- a/pager.c
+++ b/pager.c
@@ -54,7 +54,7 @@ const char *git_pager(int stdout_is_tty)
pager = getenv("PAGER");
if (!pager)
pager = DEFAULT_PAGER;
- else if (!*pager || !strcmp(pager, "cat"))
+ if (!*pager || !strcmp(pager, "cat"))
pager = NULL;
return pager;