зеркало из https://github.com/microsoft/git.git
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
This commit is contained in:
Коммит
dcedba13b3
|
@ -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)
|
||||
|
|
|
@ -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' '
|
||||
|
|
Загрузка…
Ссылка в новой задаче