aboutsummaryrefslogtreecommitdiffstats
path: root/hook.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-02-22 14:55:45 -0800
committerJunio C Hamano <gitster@pobox.com>2023-02-22 14:55:45 -0800
commit5048df67b295baeaaa6dafb16ff712bd2a62731a (patch)
tree3c1325ae2d6ddb123323fc30452dd56043e66c51 /hook.c
parentMerge branch 'ab/various-leak-fixes' (diff)
parenthook: support a --to-stdin=<path> option (diff)
downloadgit-5048df67b295baeaaa6dafb16ff712bd2a62731a.tar.gz
git-5048df67b295baeaaa6dafb16ff712bd2a62731a.zip
Merge branch 'ab/hook-api-with-stdin'
Extend the run-hooks API to allow feeding data from the standard input when running the hook script(s). * ab/hook-api-with-stdin: hook: support a --to-stdin=<path> option sequencer: use the new hook API for the simpler "post-rewrite" call hook API: support passing stdin to hooks, convert am's 'post-rewrite' run-command: allow stdin for run_processes_parallel run-command.c: remove dead assignment in while-loop
Diffstat (limited to 'hook.c')
-rw-r--r--hook.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/hook.c b/hook.c
index a4fa1031f2..1a84831863 100644
--- a/hook.c
+++ b/hook.c
@@ -55,6 +55,11 @@ static int pick_next_hook(struct child_process *cp,
cp->no_stdin = 1;
strvec_pushv(&cp->env, hook_cb->options->env.v);
+ /* reopen the file for stdin; run_command closes it. */
+ if (hook_cb->options->path_to_stdin) {
+ cp->no_stdin = 0;
+ cp->in = xopen(hook_cb->options->path_to_stdin, O_RDONLY);
+ }
cp->stdout_to_stderr = 1;
cp->trace2_hook_name = hook_cb->hook_name;
cp->dir = hook_cb->options->dir;