static struct command *commands;
-static const char update_hook[] = "hooks/update";
static const char pre_receive_hook[] = "hooks/pre-receive";
static const char post_receive_hook[] = "hooks/post-receive";
return hook_status(code, hook_name);
}
+static int run_update_hook(struct command *cmd)
+{
+ static const char update_hook[] = "hooks/update";
+ struct child_process proc;
+ const char *argv[5];
+
+ if (access(update_hook, X_OK) < 0)
+ return 0;
+
+ argv[0] = update_hook;
+ argv[1] = cmd->ref_name;
+ argv[2] = sha1_to_hex(cmd->old_sha1);
+ argv[3] = sha1_to_hex(cmd->new_sha1);
+ argv[4] = NULL;
+
+ memset(&proc, 0, sizeof(proc));
+ proc.argv = argv;
+ proc.no_stdin = 1;
+ proc.stdout_to_stderr = 1;
+
+ return hook_status(run_command(&proc), update_hook);
+}
+
static const char *update(struct command *cmd)
{
const char *name = cmd->ref_name;
return "non-fast forward";
}
}
- if (run_hook(update_hook, cmd, 1)) {
+ if (run_update_hook(cmd)) {
error("hook declined to update %s", name);
return "hook declined";
}