• Jeff King's avatar
    pager: turn on "cat" optimization for DEFAULT_PAGER · ed016612
    Jeff King authored
    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 402461aa (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, a3d023d0 (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: default avatarDale R. Worley <[email protected]>
    Suggested-by: Matthieu Moy's avatarMatthieu Moy <[email protected]>
    Signed-off-by: default avatarJeff King <[email protected]>
    Signed-off-by: default avatarJunio C Hamano <[email protected]>
pager.c 3.46 KB