mirror of
https://github.com/git/git.git
synced 2024-06-01 22:56:10 +02:00
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:
commit
dcedba13b3
|
@ -307,7 +307,6 @@ enum child_errcode {
|
||||||
CHILD_ERR_DUP2,
|
CHILD_ERR_DUP2,
|
||||||
CHILD_ERR_CLOSE,
|
CHILD_ERR_CLOSE,
|
||||||
CHILD_ERR_SIGPROCMASK,
|
CHILD_ERR_SIGPROCMASK,
|
||||||
CHILD_ERR_ENOENT,
|
|
||||||
CHILD_ERR_SILENT,
|
CHILD_ERR_SILENT,
|
||||||
CHILD_ERR_ERRNO
|
CHILD_ERR_ERRNO
|
||||||
};
|
};
|
||||||
|
@ -390,9 +389,6 @@ static void child_err_spew(struct child_process *cmd, struct child_err *cerr)
|
||||||
case CHILD_ERR_SIGPROCMASK:
|
case CHILD_ERR_SIGPROCMASK:
|
||||||
error_errno("sigprocmask failed restoring signals");
|
error_errno("sigprocmask failed restoring signals");
|
||||||
break;
|
break;
|
||||||
case CHILD_ERR_ENOENT:
|
|
||||||
error_errno("cannot run %s", cmd->args.v[0]);
|
|
||||||
break;
|
|
||||||
case CHILD_ERR_SILENT:
|
case CHILD_ERR_SILENT:
|
||||||
break;
|
break;
|
||||||
case CHILD_ERR_ERRNO:
|
case CHILD_ERR_ERRNO:
|
||||||
|
@ -846,13 +842,9 @@ int start_command(struct child_process *cmd)
|
||||||
execve(argv.v[0], (char *const *) argv.v,
|
execve(argv.v[0], (char *const *) argv.v,
|
||||||
(char *const *) childenv);
|
(char *const *) childenv);
|
||||||
|
|
||||||
if (errno == ENOENT) {
|
if (cmd->silent_exec_failure && errno == ENOENT)
|
||||||
if (cmd->silent_exec_failure)
|
child_die(CHILD_ERR_SILENT);
|
||||||
child_die(CHILD_ERR_SILENT);
|
child_die(CHILD_ERR_ERRNO);
|
||||||
child_die(CHILD_ERR_ENOENT);
|
|
||||||
} else {
|
|
||||||
child_die(CHILD_ERR_ERRNO);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
atfork_parent(&as);
|
atfork_parent(&as);
|
||||||
if (cmd->pid < 0)
|
if (cmd->pid < 0)
|
||||||
|
|
|
@ -156,25 +156,15 @@ test_expect_success 'git hook run a hook with a bad shebang' '
|
||||||
mkdir bad-hooks &&
|
mkdir bad-hooks &&
|
||||||
write_script bad-hooks/test-hook "/bad/path/no/spaces" </dev/null &&
|
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 \
|
test_expect_code 1 git \
|
||||||
-c core.hooksPath=bad-hooks \
|
-c core.hooksPath=bad-hooks \
|
||||||
hook run test-hook >out 2>err &&
|
hook run test-hook >out 2>err &&
|
||||||
test_must_be_empty out &&
|
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' '
|
test_expect_success 'stdin to hooks' '
|
||||||
|
|
Loading…
Reference in New Issue