]> source.dussan.org Git - jgit.git/commitdiff
[pgm] Add option --heads for ls-remote 83/37383/3
authorMatthias Sohn <matthias.sohn@sap.com>
Sun, 23 Nov 2014 23:41:39 +0000 (00:41 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 16 Dec 2014 14:28:16 +0000 (15:28 +0100)
TODO: find a way to use option -h which is already captured by
TextBuiltin's option --help which also uses the alias -h.

Bug: 444072
Change-Id: Ie66584c2fc7fc224014a43cf928547703dd9d213
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/LsRemoteTest.java
org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java

index 695dea831e1d293cb84d70dd6a8e2cbf79fdc038..f03edb06932a5e72c8bad18b5694d78212f58075 100644 (file)
@@ -93,4 +93,15 @@ public class LsRemoteTest extends CLIRepositoryTestCase {
                                "d0b1ef2b3dea02bb2ca824445c04e6def012c32c       refs/tags/tag3^{}",
                                "" }, result.toArray());
        }
+
+       @Test
+       public void testLsRemoteHeads() throws Exception {
+               final List<String> result = CLIGitCommand.execute(
+                               "git ls-remote --heads "
+                               + db.getDirectory(), db);
+               assertArrayEquals(new String[] {
+                               "d0b1ef2b3dea02bb2ca824445c04e6def012c32c       refs/heads/master",
+                               "d0b1ef2b3dea02bb2ca824445c04e6def012c32c       refs/heads/test",
+                               "" }, result.toArray());
+       }
 }
index bdf05e901a247fffd6a8a85a2cfb9769d1519177..52a21f72165cd6c044d91b0add39a837f9992c1d 100644 (file)
@@ -203,6 +203,7 @@ usage_Gc=Cleanup unnecessary files and optimize the local repository
 usage_Glog=View commit history as a graph
 usage_IndexPack=Build pack index file for an existing packed archive
 usage_LsRemote=List references in a remote repository
+usage_lsRemoteHeads=Show only refs starting with refs/heads
 usage_LsTree=List the contents of a tree object
 usage_MakeCacheTree=Show the current cache tree structure
 usage_MergeBase=Find as good common ancestors as possible for a merge
index 0200d8cfde8dd4e14a3b510d668dcb16bf5521ff..096d8528d4b7c1025da2dce76704c576920c94d0 100644 (file)
@@ -58,6 +58,9 @@ import org.kohsuke.args4j.Option;
 
 @Command(common = true, usage = "usage_LsRemote")
 class LsRemote extends TextBuiltin {
+       @Option(name = "--heads", usage = "usage_lsRemoteHeads")
+       private boolean heads;
+
        @Option(name = "--timeout", metaVar = "metaVar_service", usage = "usage_abortConnectionIfNoActivity")
        int timeout = -1;
 
@@ -67,7 +70,7 @@ class LsRemote extends TextBuiltin {
        @Override
        protected void run() throws Exception {
                LsRemoteCommand command = Git.lsRemoteRepository().setRemote(remote)
-                               .setTimeout(timeout);
+                               .setTimeout(timeout).setHeads(heads);
                TreeSet<Ref> refs = new TreeSet<Ref>(new Comparator<Ref>() {
 
                        public int compare(Ref r1, Ref r2) {