Don't run post-update hook unless a ref changed
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>
Shawn O. Pearce committed
Mar 7, 2007 at 16:50 UTC
3e6e152c7496c1acd298ec2b916d62acb56f11c0
1 file changed
+4
-4
receive-pack.c
+4
-4
@@ -175,14 +175,14 @@ static void run_update_post_hook(struct command *cmd)
175
int argc;
176
const char **argv;
177
178
- if (access(update_post_hook, X_OK) < 0)
179
- return;
180
- for (argc = 1, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {
178
+ for (argc = 0, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {
179
if (cmd_p->error_string)
180
continue;
181
argc++;
182
}
185
- argv = xmalloc(sizeof(*argv) * (1 + argc));
183
+ if (!argc || access(update_post_hook, X_OK) < 0)
184
+ return;
185
+ argv = xmalloc(sizeof(*argv) * (2 + argc));
186
argv[0] = update_post_hook;
187
188
for (argc = 1, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {