]> source.dussan.org Git - jgit.git/commit
Introduce exactRef to read a ref whose exact name is known 48/49548/4
authorJonathan Nieder <jrn@google.com>
Fri, 5 Jun 2015 21:14:55 +0000 (14:14 -0700)
committerJonathan Nieder <jrn@google.com>
Fri, 5 Jun 2015 21:14:55 +0000 (14:14 -0700)
commita04d1ad2f1f0f0bbb852dbddf47dd8057efa3457
treeff56f6325c41d89e07b5c10de39dde74be8b8f63
parent336092afa716c2a063c2acb3a64d9d7a6685291a
Introduce exactRef to read a ref whose exact name is known

Unlike getRef(name), the new exactRef method does not walk the search
path.  This should produce a less confusing result than getRef when the
exact ref name is known: it will not try to resolve refs/foo/bar to
refs/heads/refs/foo/bar even when refs/foo/bar does not exist.

It can be faster than both getRefs(ALL).get(name) and getRef(name)
because it only needs to examine a single ref.

A follow-up change will introduce a findRef synonym to getRef and
deprecate getRef to make the choice a caller is making more obvious
(exactRef or findRef, with the same semantics as getRefs(ALL).get and
getRefs(ALL).findRef).

Change-Id: If1bd09bcfc9919e7976a4d77f13184ea58dcda52
Signed-off-by: Jonathan Nieder <jrn@google.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefDirectoryTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java