summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4919bf0)
raw | patch | inline | side by side (parent: 4919bf0)
author | Shawn O. Pearce <spearce@spearce.org> | |
Sat, 10 Mar 2007 08:28:11 +0000 (03:28 -0500) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 12 Mar 2007 05:49:43 +0000 (22:49 -0700) |
I'm pulling the error handling used to decode the result of
run_command up into a new function so that I can reuse it.
No changes, just a simple code movement.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
run_command up into a new function so that I can reuse it.
No changes, just a simple code movement.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
receive-pack.c | patch | blob | history |
diff --git a/receive-pack.c b/receive-pack.c
index 675c88f4924086667deddc945011f6037ee8a8eb..e147076056673befd3e2828b95127fdb37c4cf7b 100644 (file)
--- a/receive-pack.c
+++ b/receive-pack.c
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)
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)