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
This commit is contained in:
Junio C Hamano
2023-02-22 14:55:45 -08:00
8 changed files with 54 additions and 36 deletions

View File

@@ -495,24 +495,12 @@ static int run_applypatch_msg_hook(struct am_state *state)
*/
static int run_post_rewrite_hook(const struct am_state *state)
{
struct child_process cp = CHILD_PROCESS_INIT;
const char *hook = find_hook("post-rewrite");
int ret;
struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
if (!hook)
return 0;
strvec_push(&opt.args, "rebase");
opt.path_to_stdin = am_path(state, "rewritten");
strvec_push(&cp.args, hook);
strvec_push(&cp.args, "rebase");
cp.in = xopen(am_path(state, "rewritten"), O_RDONLY);
cp.stdout_to_stderr = 1;
cp.trace2_hook_name = "post-rewrite";
ret = run_command(&cp);
close(cp.in);
return ret;
return run_hooks_opt("post-rewrite", &opt);
}
/**