receive-pack: remove unnecessary run_status report
The function run_status was used to report failures after a hook was run. By now, the only thing that the function itself reported was the exit code of the hook (if it was non-zero). But this is redundant because it can be expected that the hook itself will have reported a suitable error. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Sixt committed
Jul 4, 2009 at 21:26 UTC
90e41a89caa464a84e13cbc9378b0348a61f713b
1 file changed
+4
-16
builtin-receive-pack.c
+4
-16
@@ -123,13 +123,6 @@ static struct command *commands;
123
static const char pre_receive_hook[] = "hooks/pre-receive";
124
static const char post_receive_hook[] = "hooks/post-receive";
125
126
-static int run_status(int code, const char *cmd_name)
127
-{
128
- if (code > 0)
129
- error("%s exited with error code %d", cmd_name, code);
130
- return code;
131
-}
132
-
126
static int run_receive_hook(const char *hook_name)
127
{
128
static char buf[sizeof(commands->old_sha1) * 2 + PATH_MAX + 4];
@@ -156,7 +149,7 @@ static int run_receive_hook(const char *hook_name)
149
150
code = start_command(&proc);
151
if (code)
159
- return run_status(code, hook_name);
152
+ return code;
153
for (cmd = commands; cmd; cmd = cmd->next) {
154
if (!cmd->error_string) {
155
size_t n = snprintf(buf, sizeof(buf), "%s %s %s\n",
@@ -168,7 +161,7 @@ static int run_receive_hook(const char *hook_name)
161
}
162
}
163
close(proc.in);
171
- return run_status(finish_command(&proc), hook_name);
164
+ return finish_command(&proc);
165
}
166
167
static int run_update_hook(struct command *cmd)
@@ -185,9 +178,8 @@ static int run_update_hook(struct command *cmd)
178
argv[3] = sha1_to_hex(cmd->new_sha1);
179
argv[4] = NULL;
180
188
- return run_status(run_command_v_opt(argv, RUN_COMMAND_NO_STDIN |
189
- RUN_COMMAND_STDOUT_TO_STDERR),
190
- update_hook);
181
+ return run_command_v_opt(argv, RUN_COMMAND_NO_STDIN |
182
+ RUN_COMMAND_STDOUT_TO_STDERR);
183
}
184
185
static int is_ref_checked_out(const char *ref)
@@ -401,7 +393,6 @@ static void run_update_post_hook(struct command *cmd)
393
argv[argc] = NULL;
394
status = run_command_v_opt(argv, RUN_COMMAND_NO_STDIN
395
| RUN_COMMAND_STDOUT_TO_STDERR);
404
- run_status(status, update_post_hook);
396
}
397
398
static void execute_commands(const char *unpacker_error)
@@ -519,7 +510,6 @@ static const char *unpack(void)
510
code = run_command_v_opt(unpacker, RUN_GIT_CMD);
511
if (!code)
512
return NULL;
522
- run_status(code, unpacker[0]);
513
return "unpack-objects abnormal exit";
514
} else {
515
const char *keeper[7];
@@ -545,7 +535,6 @@ static const char *unpack(void)
535
ip.git_cmd = 1;
536
status = start_command(&ip);
537
if (status) {
548
- run_status(status, keeper[0]);
538
return "index-pack fork failed";
539
}
540
pack_lockfile = index_pack_lockfile(ip.out);
@@ -555,7 +544,6 @@ static const char *unpack(void)
544
reprepare_packed_git();
545
return NULL;
546
}
558
- run_status(status, keeper[0]);
547
return "index-pack abnormal exit";
548
}
549
}