Skip to content

Commit 8b47c5d

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

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

builtin/receive-pack.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,25 +1128,22 @@ static const char *update(struct command *cmd, struct shallow_info *si)
11281128
static void run_update_post_hook(struct command *commands)
11291129
{
11301130
struct command *cmd;
1131-
int argc;
11321131
struct child_process proc = CHILD_PROCESS_INIT;
11331132
const char *hook;
11341133

11351134
hook = find_hook("post-update");
1136-
for (argc = 0, cmd = commands; cmd; cmd = cmd->next) {
1137-
if (cmd->error_string || cmd->did_not_exist)
1138-
continue;
1139-
argc++;
1140-
}
1141-
if (!argc || !hook)
1135+
if (!hook)
11421136
return;
11431137

1144-
argv_array_push(&proc.args, hook);
11451138
for (cmd = commands; cmd; cmd = cmd->next) {
11461139
if (cmd->error_string || cmd->did_not_exist)
11471140
continue;
1141+
if (!proc.args.argc)
1142+
argv_array_push(&proc.args, hook);
11481143
argv_array_push(&proc.args, cmd->ref_name);
11491144
}
1145+
if (!proc.args.argc)
1146+
return;
11501147

11511148
proc.no_stdin = 1;
11521149
proc.stdout_to_stderr = 1;

0 commit comments

Comments
 (0)