sequencer: use the new hook API for the simpler "post-rewrite" call

Change the invocation of the "post-rewrite" hook added in 795160457db (sequencer (rebase -i): run the post-rewrite hook, if needed, 2017-01-02) to use the new hook API. This leaves the more complex "post-rewrite" invocation added in a87a6f3c98e (commit: move post-rewrite code to libgit, 2017-11-17) here in sequencer.c unconverted. Here we can pass in a file's via the "in" file descriptor, in that case we don't have a file, but will need to write_in_full() to an "in" provide by the API. Support for that will be added to the hook API in the future, but we're not there yet. Signed-off-by: Emily Shaffer <emilyshaffer@google.com> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Emily Shaffer committed Feb 8, 2023 at 20:21 UTC 96af564d2781e76139474051c7651136d5c74652
1 file changed +4 -14
sequencer.c
+4 -14
@@ -4834,8 +4834,7 @@ cleanup_head_ref:
4834 if (!stat(rebase_path_rewritten_list(), &st) &&
4835 st.st_size > 0) {
4836 struct child_process child = CHILD_PROCESS_INIT;
4837 - const char *post_rewrite_hook =
4838 - find_hook("post-rewrite");
4837 + struct run_hooks_opt hook_opt = RUN_HOOKS_OPT_INIT;
4838
4839 child.in = open(rebase_path_rewritten_list(), O_RDONLY);
4840 child.git_cmd = 1;
@@ -4845,18 +4844,9 @@ cleanup_head_ref:
4844 /* we don't care if this copying failed */
4845 run_command(&child);
4846
4848 - if (post_rewrite_hook) {
4849 - struct child_process hook = CHILD_PROCESS_INIT;
4850 -
4851 - hook.in = open(rebase_path_rewritten_list(),
4852 - O_RDONLY);
4853 - hook.stdout_to_stderr = 1;
4854 - hook.trace2_hook_name = "post-rewrite";
4855 - strvec_push(&hook.args, post_rewrite_hook);
4856 - strvec_push(&hook.args, "rebase");
4857 - /* we don't care if this hook failed */
4858 - run_command(&hook);
4859 - }
4847 + hook_opt.path_to_stdin = rebase_path_rewritten_list();
4848 + strvec_push(&hook_opt.args, "rebase");
4849 + run_hooks_opt("post-rewrite", &hook_opt);
4850 }
4851 apply_autostash(rebase_path_autostash());
4852