aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorRobin Stocker <robin@nibor.org>2013-07-21 16:23:12 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2013-08-13 00:04:37 +0200
commit9b26e4bffb06ddf12c9c3040e3f25482655d1d89 (patch)
treef8e5b59f4e5035e72ea80c6614d43151dc879feb /org.eclipse.jgit
parent6fb8d2345b3eb0c578a5c59e74e67c202987fe6d (diff)
downloadjgit-9b26e4bffb06ddf12c9c3040e3f25482655d1d89.tar.gz
jgit-9b26e4bffb06ddf12c9c3040e3f25482655d1d89.zip
Enable LsRemoteCommand to work without local repository
It's supported by C Git and can be useful. Bug: 413388 Change-Id: I12c6c10e791cc09ee271d89eb8b8d32f53e385db Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java11
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java8
2 files changed, 18 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java
index 7a521263d5..b643cbe25d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/Git.java
@@ -138,6 +138,17 @@ public class Git {
}
/**
+ * Returns a command to list remote branches/tags without a local
+ * repository.
+ *
+ * @return a {@link LsRemoteCommand}
+ * @since 3.1
+ */
+ public static LsRemoteCommand lsRemoteRepository() {
+ return new LsRemoteCommand(null);
+ }
+
+ /**
* Returns a command object to execute a {@code init} command
*
* @see <a
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java
index 3843dc4a18..55ca58f9cb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java
@@ -61,6 +61,7 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.FetchConnection;
import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.Transport;
+import org.eclipse.jgit.transport.URIish;
/**
* The ls-remote command
@@ -82,6 +83,8 @@ public class LsRemoteCommand extends
/**
* @param repo
+ * local repository or null for operation without local
+ * repository
*/
public LsRemoteCommand(Repository repo) {
super(repo);
@@ -155,7 +158,10 @@ public class LsRemoteCommand extends
Transport transport = null;
FetchConnection fc = null;
try {
- transport = Transport.open(repo, remote);
+ if (repo != null)
+ transport = Transport.open(repo, remote);
+ else
+ transport = Transport.open(new URIish(remote));
transport.setOptionUploadPack(uploadPack);
configure(transport);
Collection<RefSpec> refSpecs = new ArrayList<RefSpec>(1);