aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorJonathan Nieder <jrn@google.com>2015-11-11 15:50:39 -0800
committerJonathan Nieder <jrn@google.com>2018-12-26 19:29:27 -0800
commitb2ec6405e4f3321e64bdbc2287435b78fabef971 (patch)
treec248bffc9141f130782a54055705bbfb28ecca4e /org.eclipse.jgit.test
parent9895338de1c92d09fe82ec927e5ffd2da0973084 (diff)
downloadjgit-b2ec6405e4f3321e64bdbc2287435b78fabef971.tar.gz
jgit-b2ec6405e4f3321e64bdbc2287435b78fabef971.zip
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>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefDirectoryTest.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefDirectoryTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefDirectoryTest.java
index 56346e1d85..3db74688f4 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefDirectoryTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefDirectoryTest.java
@@ -48,6 +48,7 @@ import static org.eclipse.jgit.lib.Constants.R_HEADS;
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;
@@ -1099,6 +1100,28 @@ public class RefDirectoryTest extends LocalDiskRepositoryTestCase {
}
@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
// exactly the first 40 bytes of the file and nothing further on