summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Borowitz <dborowitz@google.com>2015-03-12 10:59:02 -0700
committerDave Borowitz <dborowitz@google.com>2015-03-12 12:46:26 -0700
commit0b625445ef4aa6dc5883336948015804b462de1d (patch)
tree8bb6b5360a39863234ca995cd634e06d1b062419
parent828721826ab61ceef064d57f804db91a4b9a47f3 (diff)
downloadjgit-0b625445ef4aa6dc5883336948015804b462de1d.tar.gz
jgit-0b625445ef4aa6dc5883336948015804b462de1d.zip
TestRepository: Support committing to unborn symref
Change-Id: I6bcee635adda7c929f6fa68ef20438fe77e49184
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java3
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/junit/TestRepositoryTest.java10
2 files changed, 11 insertions, 2 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
index a299d144d4..371e139a88 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
@@ -887,9 +887,8 @@ public class TestRepository<R extends Repository> {
branch = b;
Ref ref = db.getRef(branch.ref);
- if (ref != null) {
+ if (ref != null && ref.getObjectId() != null)
parent(pool.parseCommit(ref.getObjectId()));
- }
}
CommitBuilder(CommitBuilder prior) throws Exception {
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/junit/TestRepositoryTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/junit/TestRepositoryTest.java
index cc8ed504d0..87ce011763 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/junit/TestRepositoryTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/junit/TestRepositoryTest.java
@@ -265,6 +265,16 @@ public class TestRepositoryTest {
assertEquals("bar contents", blobAsString(amended, "bar"));
}
+ @Test
+ public void commitToUnbornHead() throws Exception {
+ repo.updateRef("HEAD").link("refs/heads/master");
+ RevCommit root = tr.branch("HEAD").commit().create();
+ Ref ref = repo.getRef(Constants.HEAD);
+ assertEquals(root, ref.getObjectId());
+ assertTrue(ref.isSymbolic());
+ assertEquals("refs/heads/master", ref.getTarget().getName());
+ }
+
private String blobAsString(AnyObjectId treeish, String path)
throws Exception {
RevObject obj = tr.get(rw.parseTree(treeish), path);