Allow using Built-in SSH with non-default port on git >= 2.16

Git tries to auto-detect ssh executable type to use correct command line. It detects Built-in SSH as simple, which does not support specifying port.
Git 2.16 started to error out when port is specified in the URL and simple ssh is used.
See https://public-inbox.org/git/20171120213101.yquv2ywyjajjtr5x@aiede.mtv.corp.google.com/

Git can be configured to treat builtin SSH as a regular ssh client with GIT_SSH_VARIANT environment variable set to ssh

Fixes IDEA-185221
This commit is contained in:
Dmitriy Smirnov
2018-02-28 01:57:09 +03:00
parent d9c0afa78a
commit f888e9005e
2 changed files with 5 additions and 0 deletions
@@ -38,6 +38,10 @@ public interface GitSSHHandler {
* Name of environment variable for SSH executable
*/
@NonNls String GIT_SSH_ENV = "GIT_SSH";
/**
* Name of environment variable for SSH executable variant
*/
@NonNls String GIT_SSH_VAR = "GIT_SSH_VARIANT";
/**
* Name of the handler
*/
@@ -110,6 +110,7 @@ class GitHandlerAuthenticationManager implements AutoCloseable {
private void prepareSshAuth() throws IOException {
GitXmlRpcSshService ssh = ServiceManager.getService(GitXmlRpcSshService.class);
myHandler.addCustomEnvironmentVariable(GitSSHHandler.GIT_SSH_ENV, ssh.getScriptPath().getPath());
myHandler.addCustomEnvironmentVariable(GitSSHHandler.GIT_SSH_VAR, "ssh");
mySshHandler = ssh.registerHandler(new GitSSHGUIHandler(myProject, myHandler.isIgnoreAuthenticationRequest()), myProject);
myHandler.addCustomEnvironmentVariable(GitSSHHandler.SSH_HANDLER_ENV, mySshHandler.toString());
int port = ssh.getXmlRcpPort();