Skip to content

Commit fd7c41e

Browse files
committed
Merge branch 'rs/update-hook-optim' into maint
Code clean-up. * rs/update-hook-optim: receive-pack: simplify run_update_post_hook()
2 parents fb0ab97 + dce96c4 commit fd7c41e

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

builtin/receive-pack.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,25 +1125,22 @@ static const char *update(struct command *cmd, struct shallow_info *si)
11251125
static void run_update_post_hook(struct command *commands)
11261126
{
11271127
struct command *cmd;
1128-
int argc;
11291128
struct child_process proc = CHILD_PROCESS_INIT;
11301129
const char *hook;
11311130

11321131
hook = find_hook("post-update");
1133-
for (argc = 0, cmd = commands; cmd; cmd = cmd->next) {
1134-
if (cmd->error_string || cmd->did_not_exist)
1135-
continue;
1136-
argc++;
1137-
}
1138-
if (!argc || !hook)
1132+
if (!hook)
11391133
return;
11401134

1141-
argv_array_push(&proc.args, hook);
11421135
for (cmd = commands; cmd; cmd = cmd->next) {
11431136
if (cmd->error_string || cmd->did_not_exist)
11441137
continue;
1138+
if (!proc.args.argc)
1139+
argv_array_push(&proc.args, hook);
11451140
argv_array_push(&proc.args, cmd->ref_name);
11461141
}
1142+
if (!proc.args.argc)
1143+
return;
11471144

11481145
proc.no_stdin = 1;
11491146
proc.stdout_to_stderr = 1;

0 commit comments

Comments
 (0)