aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2018-02-14 18:18:43 -0500
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2018-02-14 18:18:43 -0500
commit282dc592da152a224f58df6b21fd5f594a8778fb (patch)
tree03943ab5fc1b94d92a73326346ecc15d8e0db5c6 /org.eclipse.jgit
parent184ddc5afaba07818c6360258f6326c347b5bae2 (diff)
parentd2d22e147144aece73eabb6cadb4b5ab7b376e07 (diff)
downloadjgit-282dc592da152a224f58df6b21fd5f594a8778fb.tar.gz
jgit-282dc592da152a224f58df6b21fd5f594a8778fb.zip
Merge "Merge branch 'stable-4.10'"
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java
index 6b7a1bcd6d..c38182741d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java
@@ -121,7 +121,6 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
config = OpenSshConfig.get(fs);
final OpenSshConfig.Host hc = config.lookup(host);
- host = hc.getHostName();
if (port <= 0)
port = hc.getPort();
if (user == null)
@@ -193,13 +192,18 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
return e.getCause() == null && e.getMessage().equals("Auth cancel"); //$NON-NLS-1$
}
- private Session createSession(CredentialsProvider credentialsProvider,
+ // Package visibility for tests
+ Session createSession(CredentialsProvider credentialsProvider,
FS fs, String user, final String pass, String host, int port,
final OpenSshConfig.Host hc) throws JSchException {
final Session session = createSession(hc, user, host, port, fs);
// Jsch will have overridden the explicit user by the one from the SSH
// config file...
setUserName(session, user);
+ // Jsch will also have overridden the port.
+ if (port > 0 && port != session.getPort()) {
+ session.setPort(port);
+ }
// We retry already in getSession() method. JSch must not retry
// on its own.
session.setConfig("MaxAuthTries", "1"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -480,4 +484,14 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
}
}
}
+
+ /**
+ * Set the {@link OpenSshConfig} to use. Intended for use in tests.
+ *
+ * @param config
+ * to use
+ */
+ void setConfig(OpenSshConfig config) {
+ this.config = config;
+ }
}