receive-pack: convert push-to-checkout hook to hook.h

Move the push-to-checkout hook away from run-command.h to and over to the new hook.h library. This removes the last direct user of run_hook_le(), so we could remove that function now, but let's leave that to a follow-up cleanup commit. Signed-off-by: Emily Shaffer <emilyshaffer@google.com> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Acked-by: Emily Shaffer <emilyshaffer@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Emily Shaffer committed Dec 22, 2021 at 04:59 UTC 306f445ed16065dfd03553c8a990037b2daf4f05
1 file changed +5 -2
builtin/receive-pack.c
+5 -2
@@ -1424,9 +1424,12 @@ static const char *push_to_checkout(unsigned char *hash,
1424 struct strvec *env,
1425 const char *work_tree)
1426 {
1427 + struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
1428 +
1429 strvec_pushf(env, "GIT_WORK_TREE=%s", absolute_path(work_tree));
1428 - if (run_hook_le(env->v, push_to_checkout_hook,
1429 - hash_to_hex(hash), NULL))
1430 + strvec_pushv(&opt.env, env->v);
1431 + strvec_push(&opt.args, hash_to_hex(hash));
1432 + if (run_hooks_opt(push_to_checkout_hook, &opt))
1433 return "push-to-checkout hook declined";
1434 else
1435 return NULL;