From 29c5f49f635f136c4595d43af74dd6106ad53c19 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Fri, 17 Nov 2017 22:16:31 +0100 Subject: [PATCH] Fix NPE in TransportGitSsh.ExtSession.exec() Bug: 527383 Change-Id: I965860b4e0e9aa1adf6a1bb0735940cbd22adced Signed-off-by: Matthias Sohn --- .../jgit/transport/TransportGitSsh.java | 20 +++++++++++-------- 1 file 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 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 -- 2.39.5