strbuf_release(&sb);
}
+/**
+ * Runs applypatch-msg hook. Returns its exit code.
+ */
+static int run_applypatch_msg_hook(struct am_state *state)
+{
+ int ret;
+
+ assert(state->msg);
+ ret = run_hook_le(NULL, "applypatch-msg", am_path(state, "final-commit"), NULL);
+
+ if (!ret) {
+ free(state->msg);
+ state->msg = NULL;
+ if (read_commit_msg(state) < 0)
+ die(_("'%s' was deleted by the applypatch-msg hook"),
+ am_path(state, "final-commit"));
+ }
+
+ return ret;
+}
+
/**
* Runs post-rewrite hook. Returns it exit code.
*/
const char *reflog_msg, *author;
struct strbuf sb = STRBUF_INIT;
+ if (run_hook_le(NULL, "pre-applypatch", NULL))
+ exit(1);
+
if (write_cache_as_tree(tree, 0, NULL))
die(_("git write-tree failed to write a tree"));
write_commit_msg(state);
}
+ if (run_applypatch_msg_hook(state))
+ exit(1);
+
say(state, stdout, _("Applying: %.*s"), linelen(state->msg), state->msg);
apply_status = run_apply(state, NULL);