]> source.dussan.org Git - jgit.git/commit
Fallback exactRef: Do not ignore symrefs to unborn branch 50/60150/2
authorJonathan Nieder <jrn@google.com>
Wed, 11 Nov 2015 18:42:46 +0000 (10:42 -0800)
committerJonathan Nieder <jrn@google.com>
Thu, 12 Nov 2015 19:59:51 +0000 (14:59 -0500)
commit7dcb50a04a03a96e7514a8598eaf9bb052af867e
tree5eb6d9979045c2eff11fe94cfa066f3cb8c1e5e3
parent797f94d3319a6bea2cacce707a6a5ee67f00ea17
Fallback exactRef: Do not ignore symrefs to unborn branch

When asked to read a symref pointing to a branch-yet-to-be-born (such
as HEAD in a newly initialized repository), getRef and getRefs provide
different results.

getRef: SymbolicRef[HEAD -> refs/heads/master=00000000]
getRefs and getAdditionalRefs: nothing

exactRef should match the getRef behavior: it is meant to be a
simpler, faster version of getRef that lets you search for a ref
without resolving it using the search path without other semantic
changes.  But the fallback implementation of exactRef relies on getRefs
and produces null for this case.

Luckily the in-tree RefDatabase implementations override exactRef and
get the correct behavior.  But any out-of-tree storage backend that
doesn't inherit from DfsRefDatabase or RefDirectory would still return
null when it shouldn't.

Let the fallback implementation use getRef instead to avoid this.
This means that exactRef would waste some effort traversing the ref
search path when the named ref is not found --- but subclasses tend to
override exactRef for performance already, so in the default
implementation correctness is more important.

Bug: 478865
Change-Id: I60f04e3ce3bf4731640ffd2433d329e621330029
org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java