Use exactRef() when possible

This avoids ambiguous lookups when refs/heads/refs/meta/config exists.
Instead only refs/meta/config or nothing is returned.

exactRef() can also be optimized by JGit implementations to lookup a
ref, potentially saving time by avoiding unnecessary reads of the
storage system.

Change-Id: I1fd6750e7dce935597cf46331fe7cb6dc21473bb
This commit is contained in:
Shawn Pearce
2015-06-20 18:36:45 -07:00
parent 56e12f2277
commit 9f1d70c7c7
26 changed files with 86 additions and 73 deletions

View File

@@ -41,7 +41,7 @@ public class ProjectUtil {
IOException {
final Repository repo = repoManager.openRepository(branch.getParentKey());
try {
boolean exists = repo.getRef(branch.get()) != null;
boolean exists = repo.getRefDatabase().exactRef(branch.get()) != null;
if (!exists) {
exists = repo.getFullBranch().equals(branch.get());
}