diff --git a/src/libgit2/transports/ssh_exec.c b/src/libgit2/transports/ssh_exec.c index af6e18253..91d46a382 100644 --- a/src/libgit2/transports/ssh_exec.c +++ b/src/libgit2/transports/ssh_exec.c @@ -121,6 +121,7 @@ GIT_INLINE(int) ensure_transport_state( static int get_ssh_cmdline( git_vector *args, + bool *use_shell, ssh_exec_subtransport *transport, git_net_url *url, const char *command) @@ -152,8 +153,12 @@ static int get_ssh_cmdline( if ((error = git_repository_config_snapshot(&cfg, repo)) < 0) return error; - if ((error = git__getenv(&ssh_cmd, "GIT_SSH")) == 0) - ; + if ((error = git__getenv(&ssh_cmd, "GIT_SSH_COMMAND")) == 0) + *use_shell = true; + else if (error != GIT_ENOTFOUND) + goto done; + else if ((error = git__getenv(&ssh_cmd, "GIT_SSH")) == 0) + *use_shell = false; else if (error != GIT_ENOTFOUND) goto done; else if ((error = git_config__get_string_buf(&ssh_cmd, cfg, "core.sshcommand")) < 0 && error != GIT_ENOTFOUND) @@ -213,6 +218,7 @@ static int start_ssh( git_process_options process_opts = GIT_PROCESS_OPTIONS_INIT; git_net_url url = GIT_NET_URL_INIT; git_vector args = GIT_VECTOR_INIT; + bool use_shell = false; const char *command; int error; @@ -243,9 +249,12 @@ static int start_ssh( if (error < 0) goto done; - if ((error = get_ssh_cmdline(&args, transport, &url, command)) < 0) + if ((error = get_ssh_cmdline(&args, &use_shell, + transport, &url, command)) < 0) goto done; + process_opts.use_shell = use_shell; + if ((error = git_process_new(&transport->process, (const char **)args.contents, args.length, env, ARRAY_SIZE(env), &process_opts)) < 0 ||