diff mbox series

[v5,23/36] am: convert 'post-rewrite' hook to hook.h

Message ID patch-v5-23.36-f548e3d15e7-20210902T125110Z-avarab@gmail.com (mailing list archive)
State New, archived
Headers show
Series Run hooks via "git run hook" & hook library | expand

Commit Message

Ævar Arnfjörð Bjarmason Sept. 2, 2021, 1:11 p.m. UTC
From: Emily Shaffer <emilyshaffer@google.com>

Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/am.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/builtin/am.c b/builtin/am.c
index e444b18b64a..9e3d4d9ab44 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -467,24 +467,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;
-
-	if (!hook)
-		return 0;
-
-	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";
+	struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
 
-	ret = run_command(&cp);
+	strvec_push(&opt.args, "rebase");
+	opt.path_to_stdin = am_path(state, "rewritten");
 
-	close(cp.in);
-	return ret;
+	return run_hooks_oneshot("post-rewrite", &opt);
 }
 
 /**