summaryrefslogtreecommitdiffstats
path: root/pager.h
diff options
context:
space:
mode:
authorRubén Justo <rjusto@gmail.com>2024-07-25 15:44:39 +0200
committerJunio C Hamano <gitster@pobox.com>2024-07-25 18:03:00 +0200
commite8bd8883feb7551f7d1870403d212c77cd56071b (patch)
treeef24710139f3c25a40eda4abd37164da619bbb21 /pager.h
parentpager: do not close fd 2 unnecessarily (diff)
downloadgit-e8bd8883feb7551f7d1870403d212c77cd56071b.tar.xz
git-e8bd8883feb7551f7d1870403d212c77cd56071b.zip
pager: introduce wait_for_pager
Since f67b45f862 (Introduce trivial new pager.c helper infrastructure, 2006-02-28) we have the machinery to send our output to a pager. That machinery, once set up, does not allow us to regain the original stdio streams. In the interactive commands (i.e.: add -p) we want to use the pager for some output, while maintaining the interaction with the user. Modify the pager machinery so that we can use `setup_pager()` and, once we've finished sending the desired output for the pager, wait for the pager termination using a new function `wait_for_pager()`. Make this function reset the pager machinery before returning. One specific point to note is that we avoid forking the pager in `setup_pager()` if the configured pager is an empty string [*1*] or simply "cat" [*2*]. In these cases, `setup_pager()` does nothing and therefore `wait_for_pager()` should not be called. We could modify `setup_pager()` to return an indication of these situations, so we could avoid calling `wait_for_pager()`. However, let's avoid transferring that responsibility to the caller and instead treat the call to `wait_for_pager()` as a no-op when we know we haven't forked the pager. 1.- 402461aab1 (pager: do not fork a pager if PAGER is set to empty., 2006-04-16) 2.- caef71a535 (Do not fork PAGER=cat, 2006-04-16) Signed-off-by: Rubén Justo <rjusto@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
-rw-r--r--pager.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/pager.h b/pager.h
index b77433026d..103ecac476 100644
--- a/pager.h
+++ b/pager.h
@@ -5,6 +5,7 @@ struct child_process;
const char *git_pager(int stdout_is_tty);
void setup_pager(void);
+void wait_for_pager(void);
int pager_in_use(void);
int term_columns(void);
void term_clear_line(void);