diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2021-02-25 10:29:07 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2021-02-28 00:58:04 +0100 |
commit | f6597971991e3350df568b0cde05c014dcd69c47 (patch) | |
tree | cb61592af3f53da45174beed517b3284d7bd55c6 /org.eclipse.jgit.ssh.jsch | |
parent | 286ad23cb56ffeac77d4bfd03be575358fd5217c (diff) | |
parent | 789c0479a9294417db0375cce9f1949fe9052d8c (diff) | |
download | jgit-f6597971991e3350df568b0cde05c014dcd69c47.tar.gz jgit-f6597971991e3350df568b0cde05c014dcd69c47.zip |
Merge branch 'master' into next
* master: (143 commits)
Prepare 5.11.0-SNAPSHOT builds
JGit v5.11.0.202102240950-m3
[releng] japicmp: update last release version
IgnoreNode: include path to file for invalid .gitignore patterns
FastIgnoreRule: include bad pattern in log message
init: add config option to set default for the initial branch name
init: allow specifying the initial branch name for the new repository
Fail clone if initial branch doesn't exist in remote repository
GPG: fix reading unprotected old-format secret keys
Update Orbit to S20210216215844
Add missing bazel dependency for o.e.j.gpg.bc.test
GPG: handle extended private key format
dfs: handle short copies
[GPG] Provide a factory for the BouncyCastleGpgSigner
Fix boxing warnings
GPG: compute the keygrip to find a secret key
GPG signature verification via BouncyCastle
Post commit hook failure should not cause commit failure
Allow to define additional Hook classes outside JGit
GitHook: use default charset for output and error streams
...
Change-Id: I689f4070e79f4a0ac1c02b35698ccaab68ad2f34
Diffstat (limited to 'org.eclipse.jgit.ssh.jsch')
-rw-r--r-- | org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/JschSession.java | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/JschSession.java b/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/JschSession.java index 858bdf3f7f..c7d0941b62 100644 --- a/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/JschSession.java +++ b/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/JschSession.java @@ -22,7 +22,9 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; @@ -44,7 +46,7 @@ import com.jcraft.jsch.SftpException; * {@link org.eclipse.jgit.transport.JschConfigSessionFactory} is used to create * the actual session passed to the constructor. */ -public class JschSession implements RemoteSession { +public class JschSession implements RemoteSession2 { final Session sock; final URIish uri; @@ -65,7 +67,14 @@ public class JschSession implements RemoteSession { /** {@inheritDoc} */ @Override public Process exec(String command, int timeout) throws IOException { - return new JschProcess(command, timeout); + return exec(command, Collections.emptyMap(), timeout); + } + + /** {@inheritDoc} */ + @Override + public Process exec(String command, Map<String, String> environment, + int timeout) throws IOException { + return new JschProcess(command, environment, timeout); } /** {@inheritDoc} */ @@ -124,6 +133,8 @@ public class JschSession implements RemoteSession { * * @param commandName * the command to execute + * @param environment + * environment variables to pass on * @param tms * the timeout value, in seconds, for the command. * @throws TransportException @@ -132,11 +143,17 @@ public class JschSession implements RemoteSession { * @throws IOException * on problems opening streams */ - JschProcess(String commandName, int tms) - throws TransportException, IOException { + JschProcess(String commandName, Map<String, String> environment, + int tms) throws TransportException, IOException { timeout = tms; try { channel = (ChannelExec) sock.openChannel("exec"); //$NON-NLS-1$ + if (environment != null) { + for (Map.Entry<String, String> envVar : environment + .entrySet()) { + channel.setEnv(envVar.getKey(), envVar.getValue()); + } + } channel.setCommand(commandName); setupStreams(); channel.connect(timeout > 0 ? timeout * 1000 : 0); |