RefDirectory: Do not use search path to find additional refs
Psuedorefs like FETCH_HEAD and MERGE_HEAD are supposed to be directly under the .git directory, not in other locations in the SEARCH_PATH like refs/ and refs/heads/. Use exactRef to access them. Change-Id: Iab8ac47008822fa78fc0691e239e518c34d7a98e Signed-off-by: Jonathan Nieder <jrn@google.com>
This commit is contained in:
parent
9895338de1
commit
b2ec6405e4
|
@ -48,6 +48,7 @@
|
|||
import static org.eclipse.jgit.lib.Constants.R_TAGS;
|
||||
import static org.eclipse.jgit.lib.Ref.Storage.LOOSE;
|
||||
import static org.eclipse.jgit.lib.Ref.Storage.NEW;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
@ -1098,6 +1099,28 @@ public void testExactRef_EmptyDatabase() throws IOException {
|
|||
assertNull(refdir.exactRef("v1.0"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAdditionalRefs_OrigHead() throws IOException {
|
||||
writeLooseRef("ORIG_HEAD", A);
|
||||
|
||||
List<Ref> refs = refdir.getAdditionalRefs();
|
||||
assertEquals(1, refs.size());
|
||||
|
||||
Ref r = refs.get(0);
|
||||
assertFalse(r.isSymbolic());
|
||||
assertEquals(A, r.getObjectId());
|
||||
assertEquals("ORIG_HEAD", r.getName());
|
||||
assertFalse(r.isPeeled());
|
||||
assertNull(r.getPeeledObjectId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAdditionalRefs_OrigHeadBranch() throws IOException {
|
||||
writeLooseRef("refs/heads/ORIG_HEAD", A);
|
||||
List<Ref> refs = refdir.getAdditionalRefs();
|
||||
assertArrayEquals(new Ref[0], refs.toArray());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRef_FetchHead() throws IOException {
|
||||
// This is an odd special case where we need to make sure we read
|
||||
|
|
|
@ -412,7 +412,7 @@ public Map<String, Ref> getRefs(String prefix) throws IOException {
|
|||
public List<Ref> getAdditionalRefs() throws IOException {
|
||||
List<Ref> ret = new LinkedList<>();
|
||||
for (String name : additionalRefsNames) {
|
||||
Ref r = getRef(name);
|
||||
Ref r = exactRef(name);
|
||||
if (r != null)
|
||||
ret.add(r);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue