summary refs log tree commit diff
path: root/pager.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-02-24 13:26:01 -0800
committerJunio C Hamano <gitster@pobox.com>2016-02-24 13:26:01 -0800
commitc3b1e8d85133e2a19d372b7c166d5b49fcbbfef2 (patch)
tree0db4cfbd62218fbf54be4160420b6e9c67cd60a0 /pager.c
parent595bfefa6c31fa6d76b686ed79b024838db5933e (diff)
parent708b8cc9a114ea1e5b90f5f52fd24ecade4e8b40 (diff)
Merge branch 'jc/am-i-v-fix'
The "v(iew)" subcommand of the interactive "git am -i" command was
broken in 2.6.0 timeframe when the command was rewritten in C.

* jc/am-i-v-fix:
  am -i: fix "v"iew
  pager: factor out a helper to prepare a child process to run the pager
  pager: lose a separate argv[]
Diffstat (limited to 'pager.c')
-rw-r--r--pager.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/pager.c b/pager.c
index e425070528..4bc048148e 100644
--- a/pager.c
+++ b/pager.c
@@ -11,7 +11,6 @@
  * something different on Windows.
  */
 
-static const char *pager_argv[] = { NULL, NULL };
 static struct child_process pager_process = CHILD_PROCESS_INIT;
 
 static void wait_for_pager(int in_signal)
@@ -64,6 +63,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));
@@ -80,14 +89,8 @@ void setup_pager(void)
 	setenv("GIT_PAGER_IN_USE", "true", 1);
 
 	/* spawn the pager */
-	pager_argv[0] = pager;
-	pager_process.use_shell = 1;
-	pager_process.argv = pager_argv;
+	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;