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

[PATCH 2/5] Don't run post-update hook unless a ref changed

From
Shawn O. Pearce <spearce@spearce.org>
Date
Mar 7, 2007, 21:50 UTC
Message-ID
<20070307215043.GB28649@spearce.org>

There is little point in executing the post-update hook if all refs had an error and were unable to be updated. In this case nothing new is reachable within the repository, and there is no state change for the post-update hook to be interested in.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 receive-pack.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/receive-pack.c b/receive-pack.c
index d39aeba..e32e301 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -175,14 +175,14 @@ static void run_update_post_hook(struct command *cmd)
 	int argc;
 	const char **argv;
 
-	if (access(update_post_hook, X_OK) < 0)
-		return;
-	for (argc = 1, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {
+	for (argc = 0, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {
 		if (cmd_p->error_string)
 			continue;
 		argc++;
 	}
-	argv = xmalloc(sizeof(*argv) * (1 + argc));
+	if (!argc || access(update_post_hook, X_OK) < 0)
+		return;
+	argv = xmalloc(sizeof(*argv) * (2 + argc));
 	argv[0] = update_post_hook;
 
 	for (argc = 1, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {
-- 
1.5.0.3.895.g09890
Message 1 of 1 in “Don't run post-update hook unless a ref changed”
  1. 2/5 Don't run post-update hook unless a ref changedShawn O. Pearce, Mar 7, 2007

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.