mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
Teach git var about GIT_PAGER
Expose the command found by setup_pager() for scripts to use. Scripts can use this to avoid repeating the logic to look for a proper pager in each command. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
44fcb4977c
commit
6361824589
18
pager.c
18
pager.c
@@ -44,12 +44,14 @@ static void wait_for_pager_signal(int signo)
|
||||
raise(signo);
|
||||
}
|
||||
|
||||
void setup_pager(void)
|
||||
const char *git_pager(void)
|
||||
{
|
||||
const char *pager = getenv("GIT_PAGER");
|
||||
const char *pager;
|
||||
|
||||
if (!isatty(1))
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
pager = getenv("GIT_PAGER");
|
||||
if (!pager) {
|
||||
if (!pager_program)
|
||||
git_config(git_default_config, NULL);
|
||||
@@ -60,6 +62,16 @@ void setup_pager(void)
|
||||
if (!pager)
|
||||
pager = "less";
|
||||
else if (!*pager || !strcmp(pager, "cat"))
|
||||
pager = NULL;
|
||||
|
||||
return pager;
|
||||
}
|
||||
|
||||
void setup_pager(void)
|
||||
{
|
||||
const char *pager = git_pager();
|
||||
|
||||
if (!pager)
|
||||
return;
|
||||
|
||||
spawned_pager = 1; /* means we are emitting to terminal */
|
||||
|
||||
Reference in New Issue
Block a user