Re: [PATCH v8 22/37] rebase: teach pre-rebase to use hook.h
From: Junio C Hamano <hidden>
Date: 2021-03-12 10:27:10
Emily Shaffer [off-list ref] writes:
quoted hunk ↗ jump to hunk
@@ -1318,6 +1319,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) char *squash_onto_name = NULL; int reschedule_failed_exec = -1; int allow_preemptive_ff = 1; + struct run_hooks_opt hook_opt; struct option builtin_rebase_options[] = { OPT_STRING(0, "onto", &options.onto_name, N_("revision"),@@ -1431,6 +1433,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) }; int i; + run_hooks_opt_init_async(&hook_opt); + if (argc == 2 && !strcmp(argv[1], "-h")) usage_with_options(builtin_rebase_usage, builtin_rebase_options);@@ -2032,9 +2036,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) } /* If a hook exists, give it a chance to interrupt*/ + strvec_pushl(&hook_opt.args, options.upstream_arg, argc ? argv[0] : NULL, NULL); if (!ok_to_skip_pre_rebase && - run_hook_le(NULL, "pre-rebase", options.upstream_arg, - argc ? argv[0] : NULL, NULL)) + run_hooks("pre-rebase", &hook_opt)) die(_("The pre-rebase hook refused to rebase."));
This may needlessly populate hook_opt.args even when run_hooks() is not triggered, but that probably is OK. Except for a place or two where we call die(), the exit path from this function after this point all eventually passes ...
quoted hunk ↗ jump to hunk
if (options.flags & REBASE_DIFFSTAT) {@@ -2114,6 +2118,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) ret = !!run_specific_rebase(&options, action); cleanup:
... this label, so everybody calls opt_clear() at the end, which is good.
+ run_hooks_opt_clear(&hook_opt); strbuf_release(&buf); strbuf_release(&revisions); free(options.head_name);