From: Kevin Sawicki Date: Sat, 26 Nov 2011 22:47:21 +0000 (-0800) Subject: Don't iterate over advertised refs when HEAD is null X-Git-Tag: v1.2.0.201112221803-r~18 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=241e03be9de1251a9e2296c043b21d61bed0fd2e;p=jgit.git 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 --- diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java index 5c98e6a28d..dbc126e895 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java @@ -226,14 +226,14 @@ public class CloneCommand extends TransportCommand { } 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;