summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--receive-pack.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/receive-pack.c b/receive-pack.c
index 675c88f492..e147076056 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -71,6 +71,29 @@ 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";
+static int hook_status(int code, const char *hook_name)
+{
+ switch (code) {
+ case 0:
+ return 0;
+ case -ERR_RUN_COMMAND_FORK:
+ return error("hook fork failed");
+ case -ERR_RUN_COMMAND_EXEC:
+ return error("hook execute failed");
+ case -ERR_RUN_COMMAND_WAITPID:
+ return error("waitpid failed");
+ case -ERR_RUN_COMMAND_WAITPID_WRONG_PID:
+ return error("waitpid is confused");
+ case -ERR_RUN_COMMAND_WAITPID_SIGNAL:
+ return error("%s died of signal", hook_name);
+ case -ERR_RUN_COMMAND_WAITPID_NOEXIT:
+ return error("%s died strangely", hook_name);
+ default:
+ error("%s exited with error code %d", hook_name, -code);
+ return -code;
+ }
+}
+
static int run_hook(const char *hook_name,
struct command *first_cmd,
int single)
@@ -108,25 +131,7 @@ static int run_hook(const char *hook_name,
free((char*)argv[argc]);
free(argv);
- switch (code) {
- case 0:
- return 0;
- case -ERR_RUN_COMMAND_FORK:
- return error("hook fork failed");
- case -ERR_RUN_COMMAND_EXEC:
- return error("hook execute failed");
- case -ERR_RUN_COMMAND_WAITPID:
- return error("waitpid failed");
- case -ERR_RUN_COMMAND_WAITPID_WRONG_PID:
- return error("waitpid is confused");
- case -ERR_RUN_COMMAND_WAITPID_SIGNAL:
- return error("%s died of signal", hook_name);
- case -ERR_RUN_COMMAND_WAITPID_NOEXIT:
- return error("%s died strangely", hook_name);
- default:
- error("%s exited with error code %d", hook_name, -code);
- return -code;
- }
+ return hook_status(code, hook_name);
}
static const char *update(struct command *cmd)