diff options
author | Stefan Lay <stefan.lay@sap.com> | 2011-08-25 11:09:52 -0400 |
---|---|---|
committer | Code Review <codereview-daemon@eclipse.org> | 2011-08-25 11:09:52 -0400 |
commit | 28a49925245df61f24b072727265a9eb530ab184 (patch) | |
tree | d02512e7895c83860e31771daf198290893b5c87 | |
parent | e54404d555356ee12761366884c4774cd9393207 (diff) | |
parent | b127fa19ebae69b318d88ac0389d779d22c7eaa0 (diff) | |
download | jgit-28a49925245df61f24b072727265a9eb530ab184.tar.gz jgit-28a49925245df61f24b072727265a9eb530ab184.zip |
Merge "Unwind loop that iterates over fetch connection refs."
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java | 31 |
1 files changed, 14 insertions, 17 deletions
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 9d036e24f0..093d6cc1b2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java @@ -73,7 +73,9 @@ public class LsRemoteCommand extends GitCommand<Collection<Ref>> { private String remote = Constants.DEFAULT_REMOTE_NAME; private boolean heads; + private boolean tags; + private String uploadPack; /** @@ -118,7 +120,7 @@ public class LsRemoteCommand extends GitCommand<Collection<Ref>> { /** * The full path of git-upload-pack on the remote host - * + * * @param uploadPack */ public void setUploadPack(String uploadPack) { @@ -134,32 +136,27 @@ public class LsRemoteCommand extends GitCommand<Collection<Ref>> { try { Collection<RefSpec> refSpecs = new ArrayList<RefSpec>(1); - if (tags) { + if (tags) refSpecs.add(new RefSpec( "refs/tags/*:refs/remotes/origin/tags/*")); - } - if (heads) { + if (heads) refSpecs.add(new RefSpec( "refs/heads/*:refs/remotes/origin/*")); - } Collection<Ref> refs; Map<String, Ref> refmap = new HashMap<String, Ref>(); FetchConnection fc = transport.openFetch(); try { refs = fc.getRefs(); - for (Ref r : refs) { - boolean found = refSpecs.isEmpty(); - for (RefSpec rs : refSpecs) { - if (rs.matchSource(r)) { - found = true; - break; - } - } - if (found) { + if (refSpecs.isEmpty()) + for (Ref r : refs) refmap.put(r.getName(), r); - } - - } + else + for (Ref r : refs) + for (RefSpec rs : refSpecs) + if (rs.matchSource(r)) { + refmap.put(r.getName(), r); + break; + } } finally { fc.close(); } |