TestRepository: Support committing to unborn symref

Change-Id: I6bcee635adda7c929f6fa68ef20438fe77e49184
This commit is contained in:
Dave Borowitz 2015-03-12 10:59:02 -07:00
parent 828721826a
commit 0b625445ef
2 changed files with 11 additions and 2 deletions

View File

@ -887,9 +887,8 @@ public class CommitBuilder {
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 {

View File

@ -265,6 +265,16 @@ public void amendCommit() throws Exception {
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);