summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cache.h3
-rw-r--r--pager.c17
2 files changed, 14 insertions, 6 deletions
diff --git a/cache.h b/cache.h
index 6bb7119..a839acc 100644
--- a/cache.h
+++ b/cache.h
@@ -210,7 +210,9 @@ struct cache_entry {
#error "CE_EXTENDED_FLAGS out of range"
#endif
+/* Forward structure decls */
struct pathspec;
+struct child_process;
/*
* Copy the sha1 and stat state of a cache entry from one to
@@ -1550,6 +1552,7 @@ extern int pager_use_color;
extern int term_columns(void);
extern int decimal_width(uintmax_t);
extern int check_pager_config(const char *cmd);
+extern void prepare_pager_args(struct child_process *, const char *pager);
extern const char *editor_program;
extern const char *askpass_program;
diff --git a/pager.c b/pager.c
index 5dbcc5a..cb28207 100644
--- a/pager.c
+++ b/pager.c
@@ -53,6 +53,16 @@ const char *git_pager(int stdout_is_tty)
return pager;
}
+void prepare_pager_args(struct child_process *pager_process, const char *pager)
+{
+ argv_array_push(&pager_process->args, pager);
+ pager_process->use_shell = 1;
+ if (!getenv("LESS"))
+ argv_array_push(&pager_process->env_array, "LESS=FRX");
+ if (!getenv("LV"))
+ argv_array_push(&pager_process->env_array, "LV=-c");
+}
+
void setup_pager(void)
{
const char *pager = git_pager(isatty(1));
@@ -69,13 +79,8 @@ void setup_pager(void)
setenv("GIT_PAGER_IN_USE", "true", 1);
/* spawn the pager */
- argv_array_push(&pager_process.args, pager);
- pager_process.use_shell = 1;
+ prepare_pager_args(&pager_process, pager);
pager_process.in = -1;
- if (!getenv("LESS"))
- argv_array_push(&pager_process.env_array, "LESS=FRX");
- if (!getenv("LV"))
- argv_array_push(&pager_process.env_array, "LV=-c");
argv_array_push(&pager_process.env_array, "GIT_PAGER_IN_USE");
if (start_command(&pager_process))
return;