summaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authorJohannes Sixt <j6t@kdbg.org>2009-07-04 21:26:40 +0200
committerJunio C Hamano <gitster@pobox.com>2009-07-06 02:44:49 -0700
commit0ac77ec3150f43a5c2a6b1e47e9db5aafe53fb72 (patch)
tree6410cfd9bdc06db787fb329f8cdf84cb38809881 /git.c
parent5709e0363a891b72eb9e9756d7fb121d9bf6a7c7 (diff)
downloadgit-0ac77ec3150f43a5c2a6b1e47e9db5aafe53fb72.tar.gz
run_command: report system call errors instead of returning error codes
The motivation for this change is that system call failures are serious errors that should be reported to the user, but only few callers took the burden to decode the error codes that the functions returned into error messages. If at all, then only an unspecific error message was given. A prominent example is this: $ git upload-pack . | : fatal: unable to run 'git-upload-pack' In this example, git-upload-pack, the external command invoked through the git wrapper, dies due to SIGPIPE, but the git wrapper does not bother to report the real cause. In fact, this very error message is copied to the syslog if git-daemon's client aborts the connection early. With this change, system call failures are reported immediately after the failure and only a generic failure code is returned to the caller. In the above example the error is now to the point: $ git upload-pack . | : error: git-upload-pack died of signal Note that there is no error report if the invoked program terminated with a non-zero exit code, because it is reasonable to expect that the invoked program has already reported an error. (But many run_command call sites nevertheless write a generic error message.) There was one special return code that was used to identify the case where run_command failed because the requested program could not be exec'd. This special case is now treated like a system call failure with errno set to ENOENT. No error is reported in this case, because the call site in git.c expects this as a normal result. Therefore, the callers that carefully decoded the return value still check for this condition. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git.c')
-rw-r--r--git.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/git.c b/git.c
index d223eab62f..03726eee5e 100644
--- a/git.c
+++ b/git.c
@@ -417,12 +417,8 @@ static void execv_dashed_external(const char **argv)
* OK to return. Otherwise, we just pass along the status code.
*/
status = run_command_v_opt(argv, 0);
- if (status != -ERR_RUN_COMMAND_EXEC) {
- if (status < 0)
- die("unable to run '%s'", argv[0]);
+ if (status >= 0 || errno != ENOENT)
exit(status);
- }
- errno = ENOENT; /* as if we called execvp */
argv[0] = tmp;