TestRepository: Support committing to unborn symref
Change-Id: I6bcee635adda7c929f6fa68ef20438fe77e49184
This commit is contained in:
parent
828721826a
commit
0b625445ef
|
@ -887,10 +887,9 @@ 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 {
|
||||
branch = prior.branch;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue