]> source.dussan.org Git - jgit.git/commitdiff
Fixed the problem with calling LsRemoteCommand without a local repository over the... 48/28048/4
authorAnton Bannykh <Anton.Bannykh@jetbrains.com>
Thu, 5 Jun 2014 13:54:01 +0000 (17:54 +0400)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Sun, 8 Jun 2014 14:42:02 +0000 (16:42 +0200)
Bug: 436695
Change-Id: Ifd69fbc04156fa4dacdcba6225768f43843eee97
Signed-off-by: Anton Bannykh <anton.bannykh@gmail.com>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.eclipse.jgit/src/org/eclipse/jgit/transport/SshTransport.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/TcpTransport.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitAnon.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java

index 16d57fa9c464e543fada452e6b3b4e5ea3da0197..6f17ebf09453e7b823f41ec8a9f9972af50502a5 100644 (file)
@@ -50,6 +50,7 @@ package org.eclipse.jgit.transport;
 import org.eclipse.jgit.errors.TransportException;
 import org.eclipse.jgit.internal.JGitText;
 import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.util.FS;
 
 /**
  * The base class for transports that use SSH protocol. This class allows
@@ -80,6 +81,18 @@ public abstract class SshTransport extends TcpTransport {
                sch = SshSessionFactory.getInstance();
        }
 
+       /**
+        * Create a new transport instance without a local repository.
+        *
+        * @param uri the URI used to access the remote repository. This must be the
+        *            URI passed to {@link #open(URIish)}.
+        * @since 3.5
+        */
+       protected SshTransport(URIish uri) {
+               super(uri);
+               sch = SshSessionFactory.getInstance();
+       }
+
        /**
         * Set SSH session factory instead of the default one for this instance of
         * the transport.
@@ -118,8 +131,10 @@ public abstract class SshTransport extends TcpTransport {
 
                final int tms = getTimeout() > 0 ? getTimeout() * 1000 : 0;
 
+               final FS fs = local == null ? FS.detect() : local.getFS();
+
                sock = sch
-                               .getSession(uri, getCredentialsProvider(), local.getFS(), tms);
+                               .getSession(uri, getCredentialsProvider(), fs, tms);
                return sock;
        }
 
index a6e53908904a3be2323a4ab0d66b314e7e29200f..fcf026cc6ef4ee1af12f88f3cce7c1ebd87e5729 100644 (file)
@@ -66,4 +66,15 @@ public abstract class TcpTransport extends Transport {
        protected TcpTransport(Repository local, URIish uri) {
                super(local, uri);
        }
+
+       /**
+        * Create a new transport instance without a local repository.
+        *
+        * @param uri the URI used to access the remote repository. This must be the
+        *            URI passed to {@link #open(URIish)}.
+        * @since 3.5
+        */
+       protected TcpTransport(URIish uri) {
+               super(uri);
+       }
 }
index 4fca19ce8099316b49a19ebc06d8d9c7becf04f6..a7f42fd873f28ccee0eaed668cb71054be06ba59 100644 (file)
@@ -100,12 +100,21 @@ class TransportGitAnon extends TcpTransport implements PackTransport {
                                throws NotSupportedException {
                        return new TransportGitAnon(local, uri);
                }
+
+               @Override
+               public Transport open(URIish uri) throws NotSupportedException, TransportException {
+                       return new TransportGitAnon(uri);
+               }
        };
 
        TransportGitAnon(final Repository local, final URIish uri) {
                super(local, uri);
        }
 
+       TransportGitAnon(final URIish uri) {
+               super(uri);
+       }
+
        @Override
        public FetchConnection openFetch() throws TransportException {
                return new TcpFetchConnection();
index dde4d20585a15e3aad9a1a2b9f8581c662793e0d..b27fa0d6b2cd4f25df3556f1765a807024d9411e 100644 (file)
@@ -126,10 +126,24 @@ public class TransportGitSsh extends SshTransport implements PackTransport {
                                throws NotSupportedException {
                        return new TransportGitSsh(local, uri);
                }
+
+               @Override
+               public Transport open(URIish uri) throws NotSupportedException, TransportException {
+                       return new TransportGitSsh(uri);
+               }
        };
 
        TransportGitSsh(final Repository local, final URIish uri) {
                super(local, uri);
+               initSshSessionFactory();
+       }
+
+       TransportGitSsh(final URIish uri) {
+               super(uri);
+               initSshSessionFactory();
+       }
+
+       private void initSshSessionFactory() {
                if (useExtSession()) {
                        setSshSessionFactory(new SshSessionFactory() {
                                @Override