]> source.dussan.org Git - jgit.git/commitdiff
Fix NPE in TransportGitSsh.ExtSession.exec() 28/111828/3
authorMatthias Sohn <matthias.sohn@sap.com>
Fri, 17 Nov 2017 21:16:31 +0000 (22:16 +0100)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Mon, 20 Nov 2017 05:35:37 +0000 (00:35 -0500)
Bug: 527383
Change-Id: I965860b4e0e9aa1adf6a1bb0735940cbd22adced
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java

index 24bc058c41e9a7777281c7de06005fd33ebc64b2..b1b910ea22f27f5c3aceb01ab611cf2abcaa2b9c 100644 (file)
@@ -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