Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions run-command.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ char *git_shell_path(void)
return xstrdup(SHELL_PATH);
#else
char *p = locate_in_PATH("sh");
if (!p)
die(_("cannot find 'sh' in PATH"));
convert_slashes(p);
return p;
#endif
Expand Down
12 changes: 12 additions & 0 deletions t/helper/test-run-command.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ static int test_stdin_pipe_feed(int hook_stdin_fd, void *cb UNUSED, void *task_c
return !(*lines_remaining);
}

static int shell_path_without_path(void)
{
char *path;

unsetenv("PATH");
path = git_shell_path();
free(path);
return 0;
}

struct testsuite {
struct string_list tests, failed;
int next;
Expand Down Expand Up @@ -450,6 +460,8 @@ int cmd__run_command(int argc, const char **argv)

if (argc > 1 && !strcmp(argv[1], "testsuite"))
return testsuite(argc - 1, argv + 1);
if (argc > 1 && !strcmp(argv[1], "shell-path-without-path"))
return shell_path_without_path();
if (!strcmp(argv[1], "inherited-handle"))
return inherit_handle(argv[0]);
if (!strcmp(argv[1], "inherited-handle-child"))
Expand Down
5 changes: 5 additions & 0 deletions t/t0061-run-command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ test_expect_success MINGW 'subprocess inherits only std handles' '
test-tool run-command inherited-handle
'

test_expect_success MINGW 'missing shell path is reported' '
test_must_fail test-tool run-command shell-path-without-path 2>err &&
test_grep "cannot find .sh. in PATH" err
'

test_expect_success 'start_command reports ENOENT (slash)' '
test-tool run-command start-command-ENOENT ./does-not-exist 2>err &&
test_grep "\./does-not-exist" err
Expand Down