git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/1] builtin/receive-pack: avoid spinning no-op sideband async threads

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 2, 2026, 21:40 UTC
Message-ID
<xmqq4imxzz90.fsf@gitster.g>
In-Reply-To
<20260302191704.1814567-2-adrian.ratiu@collabora.com>
Adrian Ratiu <adrian.ratiu@collabora.com> writes:
Show 10 quoted lines
> @@ -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?
Show 10 quoted lines
> @@ -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);
 }
Previous: Adrian RatiuNext: Adrian Ratiu
Message 3 of 7 in “Fix update hook perf regression in next”
  1. 0/1 Fix update hook perf regression in nextAdrian Ratiu, Mar 2, 2026
  2. 1/1 builtin/receive-pack: avoid spinning no-op sideband async threadsAdrian Ratiu, Mar 2, 2026
  3. Junio C HamanoMar 2, 2026
  4. Adrian RatiuMar 3, 2026
  5. Patrick SteinhardtMar 3, 2026
  6. Adrian RatiuMar 3, 2026
  7. Jeff KingMar 3, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.