Skip to content

Commit 3e6e152

Browse files
spearceJunio C Hamano
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8e663d9 commit 3e6e152

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

receive-pack.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,14 @@ static void run_update_post_hook(struct command *cmd)
175175
int argc;
176176
const char **argv;
177177

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) {
181179
if (cmd_p->error_string)
182180
continue;
183181
argc++;
184182
}
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));
186186
argv[0] = update_post_hook;
187187

188188
for (argc = 1, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {

0 commit comments

Comments
 (0)