aboutsummaryrefslogtreecommitdiff
path: root/builtin/receive-pack.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-03-02 16:01:33 -0800
committerJunio C Hamano <gitster@pobox.com>2026-03-02 16:01:33 -0800
commitec1c4d974ac74afb4f0574d29f7bbb30c1c46431 (patch)
tree5c67b74724af0e4359dfa05a6e60baf0e23af1de /builtin/receive-pack.c
parent4b12cd3ae3acbc819189758d09f9c983bde16040 (diff)
parent005f3fbe07a20dd5f7dea57f6f46cd797387e56a (diff)
downloadgit-ec1c4d974ac74afb4f0574d29f7bbb30c1c46431.tar.xz
Merge branch 'ar/run-command-hook-take-2' into ar/config-hooks
* ar/run-command-hook-take-2: builtin/receive-pack: avoid spinning no-op sideband async threads
Diffstat (limited to 'builtin/receive-pack.c')
-rw-r--r--builtin/receive-pack.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 5259f09788..bf5d7e6dd0 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -934,6 +934,9 @@ static int run_receive_hook(struct command *commands,
int saved_stderr = -1;
int ret;
+ if (!hook_exists(the_repository, hook_name))
+ return 0;
+
/* if there are no valid commands, don't invoke the hook at all. */
while (iter && skip_broken && (iter->error_string || iter->did_not_exist))
iter = iter->next;
@@ -974,12 +977,16 @@ static int run_receive_hook(struct command *commands,
static int run_update_hook(struct command *cmd)
{
+ static const char hook_name[] = "update";
struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
struct async sideband_async;
int sideband_async_started = 0;
int saved_stderr = -1;
int code;
+ if (!hook_exists(the_repository, hook_name))
+ return 0;
+
strvec_pushl(&opt.args,
cmd->ref_name,
oid_to_hex(&cmd->old_oid),
@@ -988,7 +995,7 @@ static int run_update_hook(struct command *cmd)
prepare_sideband_async(&sideband_async, &saved_stderr, &sideband_async_started);
- code = run_hooks_opt(the_repository, "update", &opt);
+ code = run_hooks_opt(the_repository, hook_name, &opt);
finish_sideband_async(&sideband_async, saved_stderr, sideband_async_started);
@@ -1668,12 +1675,16 @@ out:
static void run_update_post_hook(struct command *commands)
{
+ static const char hook_name[] = "post-update";
struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
struct async sideband_async;
struct command *cmd;
int sideband_async_started = 0;
int saved_stderr = -1;
+ if (!hook_exists(the_repository, hook_name))
+ return;
+
for (cmd = commands; cmd; cmd = cmd->next) {
if (cmd->error_string || cmd->did_not_exist)
continue;
@@ -1684,7 +1695,7 @@ static void run_update_post_hook(struct command *commands)
prepare_sideband_async(&sideband_async, &saved_stderr, &sideband_async_started);
- run_hooks_opt(the_repository, "post-update", &opt);
+ run_hooks_opt(the_repository, hook_name, &opt);
finish_sideband_async(&sideband_async, saved_stderr, sideband_async_started);
}