{"thread":{"id":"7142","subject":"[PATCH 2/5] Don't run post-update hook unless a ref changed","startedAt":"2007-03-07T21:50:43Z","lastAt":"2007-03-07T21:50:43Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"36571","messageId":"20070307215043.GB28649@spearce.org","threadId":"7142","inReplyTo":null,"subject":"[PATCH 2/5] Don't run post-update hook unless a ref changed","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-03-07T21:50:43Z","receivedAt":"2007-03-07T21:50:43Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"There is little point in executing the post-update hook if all refs\nhad an error and were unable to be updated.  In this case nothing\nnew is reachable within the repository, and there is no state change\nfor the post-update hook to be interested in.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n receive-pack.c |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/receive-pack.c b/receive-pack.c\nindex d39aeba..e32e301 100644\n--- a/receive-pack.c\n+++ b/receive-pack.c\n@@ -175,14 +175,14 @@ static void run_update_post_hook(struct command *cmd)\n \tint argc;\n \tconst char **argv;\n \n-\tif (access(update_post_hook, X_OK) < 0)\n-\t\treturn;\n-\tfor (argc = 1, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {\n+\tfor (argc = 0, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {\n \t\tif (cmd_p->error_string)\n \t\t\tcontinue;\n \t\targc++;\n \t}\n-\targv = xmalloc(sizeof(*argv) * (1 + argc));\n+\tif (!argc || access(update_post_hook, X_OK) < 0)\n+\t\treturn;\n+\targv = xmalloc(sizeof(*argv) * (2 + argc));\n \targv[0] = update_post_hook;\n \n \tfor (argc = 1, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {\n-- \n1.5.0.3.895.g09890\n"}]}