From: Junio C Hamano <gitster@pobox.com>
To: Adrian Ratiu <adrian.ratiu@collabora.com>
Cc: git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>,
Emily Shaffer <emilyshaffer@google.com>,
Jeff King <peff@peff.net>
Subject: Re: [PATCH 1/1] builtin/receive-pack: avoid spinning no-op sideband async threads
Date: Mon, 02 Mar 2026 13:40:27 -0800 [thread overview]
Message-ID: <xmqq4imxzz90.fsf@gitster.g> (raw)
In-Reply-To: <20260302191704.1814567-2-adrian.ratiu@collabora.com> (Adrian Ratiu's message of "Mon, 2 Mar 2026 21:17:04 +0200")
Adrian Ratiu <adrian.ratiu@collabora.com> writes:
> @@ -980,6 +983,9 @@ static int run_update_hook(struct command *cmd)
> int saved_stderr = -1;
> int code;
>
> + if (!hook_exists(the_repository, "update"))
> + return 0;
> +
> strvec_pushl(&opt.args,
> cmd->ref_name,
> oid_to_hex(&cmd->old_oid),
Shouldn't we consolidate the two instances of hardcoded string
"update" in this function by introducing
static const char hook_name[] = "update";
in the function scope and using it?
> @@ -1674,6 +1680,9 @@ static void run_update_post_hook(struct command *commands)
> int sideband_async_started = 0;
> int saved_stderr = -1;
>
> + if (!hook_exists(the_repository, "post-update"))
> + return;
> +
> for (cmd = commands; cmd; cmd = cmd->next) {
> if (cmd->error_string || cmd->did_not_exist)
> continue;
Ditto for "post-update".
Will queue with the following change squashed in.
builtin/receive-pack.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git c/builtin/receive-pack.c w/builtin/receive-pack.c
index 62c576c247..bf5d7e6dd0 100644
--- c/builtin/receive-pack.c
+++ w/builtin/receive-pack.c
@@ -977,13 +977,14 @@ 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, "update"))
+ if (!hook_exists(the_repository, hook_name))
return 0;
strvec_pushl(&opt.args,
@@ -994,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);
@@ -1674,13 +1675,14 @@ static const char *update(struct command *cmd, struct shallow_info *si)
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, "post-update"))
+ if (!hook_exists(the_repository, hook_name))
return;
for (cmd = commands; cmd; cmd = cmd->next) {
@@ -1693,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);
}
next prev parent reply other threads:[~2026-03-02 21:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 19:17 [PATCH 0/1] Fix update hook perf regression in next Adrian Ratiu
2026-03-02 19:17 ` [PATCH 1/1] builtin/receive-pack: avoid spinning no-op sideband async threads Adrian Ratiu
2026-03-02 21:40 ` Junio C Hamano [this message]
2026-03-03 12:47 ` Adrian Ratiu
2026-03-03 6:11 ` Patrick Steinhardt
2026-03-03 12:45 ` Adrian Ratiu
2026-03-03 13:28 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq4imxzz90.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=adrian.ratiu@collabora.com \
--cc=emilyshaffer@google.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.