diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2017-11-17 22:16:31 +0100 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2017-11-20 00:35:37 -0500 |
commit | 29c5f49f635f136c4595d43af74dd6106ad53c19 (patch) | |
tree | 3592d69c8102c233d21fde504e0c99921f947b6c | |
parent | 809b9f8d5c07c7ec46acee28608d2da5d1b6bf8e (diff) | |
download | jgit-29c5f49f635f136c4595d43af74dd6106ad53c19.tar.gz jgit-29c5f49f635f136c4595d43af74dd6106ad53c19.zip |
Fix NPE in TransportGitSsh.ExtSession.exec()
Bug: 527383
Change-Id: I965860b4e0e9aa1adf6a1bb0735940cbd22adced
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java index 24bc058c41..b1b910ea22 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java @@ -242,14 +242,7 @@ public class TransportGitSsh extends SshTransport implements PackTransport { args.add(getURI().getHost()); args.add(command); - ProcessBuilder pb = new ProcessBuilder(); - pb.command(args); - - File directory = local.getDirectory(); - if (directory != null) - pb.environment().put(Constants.GIT_DIR_KEY, - directory.getPath()); - + ProcessBuilder pb = createProcess(args); try { return pb.start(); } catch (IOException err) { @@ -257,6 +250,17 @@ public class TransportGitSsh extends SshTransport implements PackTransport { } } + private ProcessBuilder createProcess(List<String> args) { + ProcessBuilder pb = new ProcessBuilder(); + pb.command(args); + File directory = local != null ? local.getDirectory() : null; + if (directory != null) { + pb.environment().put(Constants.GIT_DIR_KEY, + directory.getPath()); + } + return pb; + } + @Override public void disconnect() { // Nothing to do |