summaryrefslogtreecommitdiff
path: root/builtin/receive-pack.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-03-24 20:07:37 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-03-24 20:07:37 (GMT)
commit8b47c5de96fb50aad5b861b0a1f89a949a479f0f (patch)
tree598832f805229fa69758bb848ac85b6ae9d2e8d2 /builtin/receive-pack.c
parentbedbeb1bb31b787e1125c3c63622ff384565b271 (diff)
parentdce96c41f9d11280ba25ca3927f3e627f03eaf86 (diff)
downloadgit-8b47c5de96fb50aad5b861b0a1f89a949a479f0f.zip
git-8b47c5de96fb50aad5b861b0a1f89a949a479f0f.tar.gz
git-8b47c5de96fb50aad5b861b0a1f89a949a479f0f.tar.bz2
Merge branch 'rs/update-hook-optim'
Code clean-up. * rs/update-hook-optim: receive-pack: simplify run_update_post_hook()
Diffstat (limited to 'builtin/receive-pack.c')
-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 83492af..fb2a090 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1128,25 +1128,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;