Skip to content

Commit 96af564

Browse files
nasamuffingitster
authored andcommitted
sequencer: use the new hook API for the simpler "post-rewrite" call
Change the invocation of the "post-rewrite" hook added in 7951604 (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 a87a6f3 (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 <[email protected]> Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 917e080 commit 96af564

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

sequencer.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4834,8 +4834,7 @@ static int pick_commits(struct repository *r,
48344834
if (!stat(rebase_path_rewritten_list(), &st) &&
48354835
st.st_size > 0) {
48364836
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;
48394838

48404839
child.in = open(rebase_path_rewritten_list(), O_RDONLY);
48414840
child.git_cmd = 1;
@@ -4845,18 +4844,9 @@ static int pick_commits(struct repository *r,
48454844
/* we don't care if this copying failed */
48464845
run_command(&child);
48474846

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);
48604850
}
48614851
apply_autostash(rebase_path_autostash());
48624852

0 commit comments

Comments
 (0)