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

@@ -4844,8 +4844,7 @@ cleanup_head_ref:
if (!stat(rebase_path_rewritten_list(), &st) &&
st.st_size > 0) {
struct child_process child = CHILD_PROCESS_INIT;
const char *post_rewrite_hook =
find_hook("post-rewrite");
struct run_hooks_opt hook_opt = RUN_HOOKS_OPT_INIT;
child.in = open(rebase_path_rewritten_list(), O_RDONLY);
child.git_cmd = 1;
@@ -4855,18 +4854,9 @@ cleanup_head_ref:
/* we don't care if this copying failed */
run_command(&child);
if (post_rewrite_hook) {
struct child_process hook = CHILD_PROCESS_INIT;
hook.in = open(rebase_path_rewritten_list(),
O_RDONLY);
hook.stdout_to_stderr = 1;
hook.trace2_hook_name = "post-rewrite";
strvec_push(&hook.args, post_rewrite_hook);
strvec_push(&hook.args, "rebase");
/* we don't care if this hook failed */
run_command(&hook);
}
hook_opt.path_to_stdin = rebase_path_rewritten_list();
strvec_push(&hook_opt.args, "rebase");
run_hooks_opt("post-rewrite", &hook_opt);
}
apply_autostash(rebase_path_autostash());