Skip to content

Commit 28a4992

Browse files
stefanlayCode Review
authored andcommitted
Merge "Unwind loop that iterates over fetch connection refs."
2 parents e54404d + b127fa1 commit 28a4992

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

org.eclipse.jgit/src/org/eclipse/jgit/api/LsRemoteCommand.java

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ public class LsRemoteCommand extends GitCommand<Collection<Ref>> {
7373
private String remote = Constants.DEFAULT_REMOTE_NAME;
7474

7575
private boolean heads;
76+
7677
private boolean tags;
78+
7779
private String uploadPack;
7880

7981
/**
@@ -118,7 +120,7 @@ public void setTags(boolean tags) {
118120

119121
/**
120122
* The full path of git-upload-pack on the remote host
121-
*
123+
*
122124
* @param uploadPack
123125
*/
124126
public void setUploadPack(String uploadPack) {
@@ -134,32 +136,27 @@ public Collection<Ref> call() throws Exception {
134136

135137
try {
136138
Collection<RefSpec> refSpecs = new ArrayList<RefSpec>(1);
137-
if (tags) {
139+
if (tags)
138140
refSpecs.add(new RefSpec(
139141
"refs/tags/*:refs/remotes/origin/tags/*"));
140-
}
141-
if (heads) {
142+
if (heads)
142143
refSpecs.add(new RefSpec(
143144
"refs/heads/*:refs/remotes/origin/*"));
144-
}
145145
Collection<Ref> refs;
146146
Map<String, Ref> refmap = new HashMap<String, Ref>();
147147
FetchConnection fc = transport.openFetch();
148148
try {
149149
refs = fc.getRefs();
150-
for (Ref r : refs) {
151-
boolean found = refSpecs.isEmpty();
152-
for (RefSpec rs : refSpecs) {
153-
if (rs.matchSource(r)) {
154-
found = true;
155-
break;
156-
}
157-
}
158-
if (found) {
150+
if (refSpecs.isEmpty())
151+
for (Ref r : refs)
159152
refmap.put(r.getName(), r);
160-
}
161-
162-
}
153+
else
154+
for (Ref r : refs)
155+
for (RefSpec rs : refSpecs)
156+
if (rs.matchSource(r)) {
157+
refmap.put(r.getName(), r);
158+
break;
159+
}
163160
} finally {
164161
fc.close();
165162
}

0 commit comments

Comments
 (0)