summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki <kevin@github.com>2011-11-26 14:47:21 -0800
committerKevin Sawicki <kevin@github.com>2011-11-26 14:47:21 -0800
commit241e03be9de1251a9e2296c043b21d61bed0fd2e (patch)
tree322cae482fd961d06f2e57a28b6f4a36c4cb6c62
parentb4495d1005e6e03e921ed116614ec45499f1923d (diff)
downloadjgit-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.java6
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;