Skip to content

Commit 28eec80

Browse files
committed
Merge branch 'jc/am-i-v-fix' into maint
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[]
2 parents 9c17cca + 708b8cc commit 28eec80

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

builtin/am.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,7 @@ static int do_interactive(struct am_state *state)
18211821

18221822
if (!pager)
18231823
pager = "cat";
1824-
argv_array_push(&cp.args, pager);
1824+
prepare_pager_args(&cp, pager);
18251825
argv_array_push(&cp.args, am_path(state, "patch"));
18261826
run_command(&cp);
18271827
}

cache.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ struct cache_entry {
228228
#error "CE_EXTENDED_FLAGS out of range"
229229
#endif
230230

231+
/* Forward structure decls */
231232
struct pathspec;
233+
struct child_process;
232234

233235
/*
234236
* Copy the sha1 and stat state of a cache entry from one to
@@ -1679,6 +1681,7 @@ extern int pager_use_color;
16791681
extern int term_columns(void);
16801682
extern int decimal_width(uintmax_t);
16811683
extern int check_pager_config(const char *cmd);
1684+
extern void prepare_pager_args(struct child_process *, const char *pager);
16821685

16831686
extern const char *editor_program;
16841687
extern const char *askpass_program;

pager.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
* something different on Windows.
1212
*/
1313

14-
static const char *pager_argv[] = { NULL, NULL };
1514
static struct child_process pager_process = CHILD_PROCESS_INIT;
1615

1716
static void wait_for_pager(int in_signal)
@@ -64,6 +63,16 @@ const char *git_pager(int stdout_is_tty)
6463
return pager;
6564
}
6665

66+
void prepare_pager_args(struct child_process *pager_process, const char *pager)
67+
{
68+
argv_array_push(&pager_process->args, pager);
69+
pager_process->use_shell = 1;
70+
if (!getenv("LESS"))
71+
argv_array_push(&pager_process->env_array, "LESS=FRX");
72+
if (!getenv("LV"))
73+
argv_array_push(&pager_process->env_array, "LV=-c");
74+
}
75+
6776
void setup_pager(void)
6877
{
6978
const char *pager = git_pager(isatty(1));
@@ -80,14 +89,8 @@ void setup_pager(void)
8089
setenv("GIT_PAGER_IN_USE", "true", 1);
8190

8291
/* spawn the pager */
83-
pager_argv[0] = pager;
84-
pager_process.use_shell = 1;
85-
pager_process.argv = pager_argv;
92+
prepare_pager_args(&pager_process, pager);
8693
pager_process.in = -1;
87-
if (!getenv("LESS"))
88-
argv_array_push(&pager_process.env_array, "LESS=FRX");
89-
if (!getenv("LV"))
90-
argv_array_push(&pager_process.env_array, "LV=-c");
9194
argv_array_push(&pager_process.env_array, "GIT_PAGER_IN_USE");
9295
if (start_command(&pager_process))
9396
return;

0 commit comments

Comments
 (0)