summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2017-03-28 13:52:28 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-03-28 13:52:28 -0700
commitfd7c41ec9745a4df199492b1736c9821b6c1028f (patch)
treeb12b923e73d96c11211386bd2b4a627306cfe17f
parentMerge branch 'rs/shortlog-cleanup' into maint (diff)
parentreceive-pack: simplify run_update_post_hook() (diff)
downloadtgif-fd7c41ec9745a4df199492b1736c9821b6c1028f.tar.xz
Merge branch 'rs/update-hook-optim' into maint
Code clean-up. * rs/update-hook-optim: receive-pack: simplify run_update_post_hook()
-rw-r--r--builtin/receive-pack.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 8672825e2e..b618d52139 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1125,25 +1125,22 @@ static const char *update(struct command *cmd, struct shallow_info *si)
static void run_update_post_hook(struct command *commands)
{
struct command *cmd;
- int argc;
struct child_process proc = CHILD_PROCESS_INIT;
const char *hook;
hook = find_hook("post-update");
- for (argc = 0, cmd = commands; cmd; cmd = cmd->next) {
- if (cmd->error_string || cmd->did_not_exist)
- continue;
- argc++;
- }
- if (!argc || !hook)
+ if (!hook)
return;
- argv_array_push(&proc.args, hook);
for (cmd = commands; cmd; cmd = cmd->next) {
if (cmd->error_string || cmd->did_not_exist)
continue;
+ if (!proc.args.argc)
+ argv_array_push(&proc.args, hook);
argv_array_push(&proc.args, cmd->ref_name);
}
+ if (!proc.args.argc)
+ return;
proc.no_stdin = 1;
proc.stdout_to_stderr = 1;