Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-06-23 21:21:16 +0300
committerJunio C Hamano <gitster@pobox.com>2023-06-23 21:21:16 +0300
commitdcedba13b38978f56e5b703bfaff379a86d6e52f (patch)
treea23ef3854f56ff5e45ba534b8eddd2ecd8732e4e
parent5ee8fcdabc25ade1f8c5295575a1c20ab4f6f347 (diff)
parent6d224ac286d62bb3a10c3697f220b0c10d4b5f51 (diff)
Merge branch 'rs/run-command-exec-error-on-noent'
Simplify error message when run-command fails to start a command. * rs/run-command-exec-error-on-noent: run-command: report exec error even on ENOENT t1800: loosen matching of error message for bad shebang
-rw-r--r--run-command.c14
-rwxr-xr-xt/t1800-hook.sh20
2 files changed, 8 insertions, 26 deletions
diff --git a/run-command.c b/run-command.c
index 60c9419866..758f8534da 100644
--- a/run-command.c
+++ b/run-command.c
@@ -307,7 +307,6 @@ enum child_errcode {
CHILD_ERR_DUP2,
CHILD_ERR_CLOSE,
CHILD_ERR_SIGPROCMASK,
- CHILD_ERR_ENOENT,
CHILD_ERR_SILENT,
CHILD_ERR_ERRNO
};
@@ -390,9 +389,6 @@ static void child_err_spew(struct child_process *cmd, struct child_err *cerr)
case CHILD_ERR_SIGPROCMASK:
error_errno("sigprocmask failed restoring signals");
break;
- case CHILD_ERR_ENOENT:
- error_errno("cannot run %s", cmd->args.v[0]);
- break;
case CHILD_ERR_SILENT:
break;
case CHILD_ERR_ERRNO:
@@ -846,13 +842,9 @@ fail_pipe:
execve(argv.v[0], (char *const *) argv.v,
(char *const *) childenv);
- if (errno == ENOENT) {
- if (cmd->silent_exec_failure)
- child_die(CHILD_ERR_SILENT);
- child_die(CHILD_ERR_ENOENT);
- } else {
- child_die(CHILD_ERR_ERRNO);
- }
+ if (cmd->silent_exec_failure && errno == ENOENT)
+ child_die(CHILD_ERR_SILENT);
+ child_die(CHILD_ERR_ERRNO);
}
atfork_parent(&as);
if (cmd->pid < 0)
diff --git a/t/t1800-hook.sh b/t/t1800-hook.sh
index 3506f627b6..8b0234cf2d 100755
--- a/t/t1800-hook.sh
+++ b/t/t1800-hook.sh
@@ -156,25 +156,15 @@ test_expect_success 'git hook run a hook with a bad shebang' '
mkdir bad-hooks &&
write_script bad-hooks/test-hook "/bad/path/no/spaces" </dev/null &&
- # TODO: We should emit the same (or at least a more similar)
- # error on MINGW (essentially Git for Windows) and all other
- # platforms.. See the OS-specific code in start_command()
- if test_have_prereq !MINGW
- then
- cat >expect <<-\EOF
- fatal: cannot run bad-hooks/test-hook: ...
- EOF
- else
- cat >expect <<-\EOF
- error: cannot spawn bad-hooks/test-hook: ...
- EOF
- fi &&
test_expect_code 1 git \
-c core.hooksPath=bad-hooks \
hook run test-hook >out 2>err &&
test_must_be_empty out &&
- sed -e "s/test-hook: .*/test-hook: .../" <err >actual &&
- test_cmp expect actual
+
+ # TODO: We should emit the same (or at least a more similar)
+ # error on MINGW (essentially Git for Windows) and all other
+ # platforms.. See the OS-specific code in start_command()
+ grep -E "^(error|fatal): cannot (exec|spawn) .*bad-hooks/test-hook" err
'
test_expect_success 'stdin to hooks' '