Don't run post-update hook unless a ref changed
authorShawn O. Pearce <spearce@spearce.org>
Wed, 7 Mar 2007 21:50:43 +0000 (16:50 -0500)
committerJunio C Hamano <junkio@cox.net>
Wed, 7 Mar 2007 22:45:42 +0000 (14:45 -0800)
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>
Signed-off-by: Junio C Hamano <junkio@cox.net>
receive-pack.c
index d39aebac1e33be7b15b5662e464d93f00243cdc0..e32e301d47d357925ac214191058ab9656e0bc5c 100644 (file)
@@ -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) {