Merge "Unwind loop that iterates over fetch connection refs."
This commit is contained in:
commit
28a4992524
|
@ -73,7 +73,9 @@ public class LsRemoteCommand extends GitCommand<Collection<Ref>> {
|
||||||
private String remote = Constants.DEFAULT_REMOTE_NAME;
|
private String remote = Constants.DEFAULT_REMOTE_NAME;
|
||||||
|
|
||||||
private boolean heads;
|
private boolean heads;
|
||||||
|
|
||||||
private boolean tags;
|
private boolean tags;
|
||||||
|
|
||||||
private String uploadPack;
|
private String uploadPack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,31 +136,26 @@ public Collection<Ref> call() throws Exception {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Collection<RefSpec> refSpecs = new ArrayList<RefSpec>(1);
|
Collection<RefSpec> refSpecs = new ArrayList<RefSpec>(1);
|
||||||
if (tags) {
|
if (tags)
|
||||||
refSpecs.add(new RefSpec(
|
refSpecs.add(new RefSpec(
|
||||||
"refs/tags/*:refs/remotes/origin/tags/*"));
|
"refs/tags/*:refs/remotes/origin/tags/*"));
|
||||||
}
|
if (heads)
|
||||||
if (heads) {
|
|
||||||
refSpecs.add(new RefSpec(
|
refSpecs.add(new RefSpec(
|
||||||
"refs/heads/*:refs/remotes/origin/*"));
|
"refs/heads/*:refs/remotes/origin/*"));
|
||||||
}
|
|
||||||
Collection<Ref> refs;
|
Collection<Ref> refs;
|
||||||
Map<String, Ref> refmap = new HashMap<String, Ref>();
|
Map<String, Ref> refmap = new HashMap<String, Ref>();
|
||||||
FetchConnection fc = transport.openFetch();
|
FetchConnection fc = transport.openFetch();
|
||||||
try {
|
try {
|
||||||
refs = fc.getRefs();
|
refs = fc.getRefs();
|
||||||
for (Ref r : refs) {
|
if (refSpecs.isEmpty())
|
||||||
boolean found = refSpecs.isEmpty();
|
for (Ref r : refs)
|
||||||
for (RefSpec rs : refSpecs) {
|
|
||||||
if (rs.matchSource(r)) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (found) {
|
|
||||||
refmap.put(r.getName(), r);
|
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 {
|
} finally {
|
||||||
fc.close();
|
fc.close();
|
||||||
|
|
Loading…
Reference in New Issue