Browse Source

Don't iterate over advertised refs when HEAD is null

Moves the check from inside the loop to outside the loop
and returns immediately if the HEAD advertisded ref is null

Change-Id: I539da6cafb4f73610b8e00259e32bd4d57f4f4cc
stable-1.2
Kevin Sawicki 13 years ago
parent
commit
241e03be9d
  1. 6
      org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java

6
org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java

@ -226,14 +226,14 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
}
private Ref findBranchToCheckout(FetchResult result) {
Ref foundBranch = null;
final Ref idHEAD = result.getAdvertisedRef(Constants.HEAD);
if (idHEAD == null)
return null;
Ref foundBranch = null;
for (final Ref r : result.getAdvertisedRefs()) {
final String n = r.getName();
if (!n.startsWith(Constants.R_HEADS))
continue;
if (idHEAD == null)
continue;
if (r.getObjectId().equals(idHEAD.getObjectId())) {
foundBranch = r;
break;

Loading…
Cancel
Save