aboutsummaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-01-15 11:12:53 -0800
committerJunio C Hamano <gitster@pobox.com>2026-01-15 13:02:38 -0800
commita3d1f391d35762162356201028fb73774a6c4a8b (patch)
tree4b27ddcff1e2c2a24f34eccd2c50cb0275b39b2f /sequencer.c
parent7264e61d87e58b9d0f5e6424c47c11e9657dfb75 (diff)
downloadgit-a3d1f391d35762162356201028fb73774a6c4a8b.tar.xz
Revert "Merge branch 'ar/run-command-hook'"
This reverts commit f406b8955295d01089ba2baf35eceadff2d11cae, reversing changes made to 1627809eeff75e6ec936fc609e7be46d5eb2fa9e. It seems to have caused a few regressions, two of the three known ones we have proposed solutions for. Let's give ourselves a bit more room to maneuver during the pre-release freeze period and restart once the 2.53 ships.
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/sequencer.c b/sequencer.c
index 71ed31c774..5476d39ba9 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1292,40 +1292,32 @@ int update_head_with_reflog(const struct commit *old_head,
return ret;
}
-static int pipe_from_strbuf(int hook_stdin_fd, void *pp_cb, void *pp_task_cb UNUSED)
-{
- struct hook_cb_data *hook_cb = pp_cb;
- struct strbuf *to_pipe = hook_cb->options->feed_pipe_ctx;
- int ret;
-
- if (!to_pipe)
- BUG("pipe_from_strbuf called without feed_pipe_ctx");
-
- ret = write_in_full(hook_stdin_fd, to_pipe->buf, to_pipe->len);
- if (ret < 0 && errno != EPIPE)
- return ret;
-
- return 1; /* done writing */
-}
-
static int run_rewrite_hook(const struct object_id *oldoid,
const struct object_id *newoid)
{
- struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
+ struct child_process proc = CHILD_PROCESS_INIT;
int code;
struct strbuf sb = STRBUF_INIT;
+ const char *hook_path = find_hook(the_repository, "post-rewrite");
- strbuf_addf(&sb, "%s %s\n", oid_to_hex(oldoid), oid_to_hex(newoid));
-
- opt.feed_pipe_ctx = &sb;
- opt.feed_pipe = pipe_from_strbuf;
-
- strvec_push(&opt.args, "amend");
+ if (!hook_path)
+ return 0;
- code = run_hooks_opt(the_repository, "post-rewrite", &opt);
+ strvec_pushl(&proc.args, hook_path, "amend", NULL);
+ proc.in = -1;
+ proc.stdout_to_stderr = 1;
+ proc.trace2_hook_name = "post-rewrite";
+ code = start_command(&proc);
+ if (code)
+ return code;
+ strbuf_addf(&sb, "%s %s\n", oid_to_hex(oldoid), oid_to_hex(newoid));
+ sigchain_push(SIGPIPE, SIG_IGN);
+ write_in_full(proc.in, sb.buf, sb.len);
+ close(proc.in);
strbuf_release(&sb);
- return code;
+ sigchain_pop(SIGPIPE);
+ return finish_command(&proc);
}
void commit_post_rewrite(struct repository *r,