path: root/run-command.c
diff options
authorJohannes Sixt <>2009-07-04 19:26:39 (GMT)
committerJunio C Hamano <>2009-07-05 19:16:27 (GMT)
commit5709e0363a891b72eb9e9756d7fb121d9bf6a7c7 (patch)
tree47c33baed20745fe0f928ed86fd526ac13943622 /run-command.c
parent303e7c48eae7e140a9612ff1f9b5a95ca80b65c4 (diff)
run_command: return exit code as positive value
As a general guideline, functions in git's code return zero to indicate success and negative values to indicate failure. The run_command family of functions followed this guideline. But there are actually two different kinds of failure: - failures of system calls; - non-zero exit code of the program that was run. Usually, a non-zero exit code of the program is a failure and means a failure to the caller. Except that sometimes it does not. For example, the exit code of merge programs (e.g. external merge drivers) conveys information about how the merge failed, and not all exit calls are actually failures. Furthermore, the return value of run_command is sometimes used as exit code by the caller. This change arranges that the exit code of the program is returned as a positive value, which can now be regarded as the "result" of the function. System call failures continue to be reported as negative values. Signed-off-by: Johannes Sixt <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'run-command.c')
1 files changed, 1 insertions, 8 deletions
diff --git a/run-command.c b/run-command.c
index eb2efc3..a4e309e 100644
--- a/run-command.c
+++ b/run-command.c
@@ -241,14 +241,7 @@ static int wait_or_whine(pid_t pid)
if (!WIFEXITED(status))
code = WEXITSTATUS(status);
- switch (code) {
- case 127:
- case 0:
- return 0;
- default:
- return -code;
- }
+ return code == 127 ? -ERR_RUN_COMMAND_EXEC : code;