diff options
author | Kevin Sawicki <kevin@github.com> | 2011-11-26 14:47:21 -0800 |
---|---|---|
committer | Kevin Sawicki <kevin@github.com> | 2011-11-26 14:47:21 -0800 |
commit | 241e03be9de1251a9e2296c043b21d61bed0fd2e (patch) | |
tree | 322cae482fd961d06f2e57a28b6f4a36c4cb6c62 | |
parent | b4495d1005e6e03e921ed116614ec45499f1923d (diff) | |
download | jgit-241e03be9de1251a9e2296c043b21d61bed0fd2e.tar.gz jgit-241e03be9de1251a9e2296c043b21d61bed0fd2e.zip |
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
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java | 6 |
1 files changed, 3 insertions, 3 deletions
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<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; |