insertAndAdd(points2);
final RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
// checkout master, then create branch2 and checkout
geogig.command(CheckoutOp.class).setSource("master").call();
final Ref branch2 = geogig.command(BranchCreateOp.class).setAutoCheckout(true)
.setName("branch2").call();
insertAndAdd(points3);
final RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for " + idP3).call();
insertAndAdd(lines1);
final RevCommit c4 = geogig.command(CommitOp.class).setMessage("commit for " + idL1).call();
// Rebase branch2 onto branch1 to create the following revision graph
// o
// |
// o - master - Points 1 added
// |
// o - branch1 - Points 2 added
// |
// o - Points 3 added
// |
// o - branch2 - HEAD - Lines 1 added
Ref branch1 = geogig.command(RefParse.class).setName("branch1").call().get();
geogig.command(RebaseOp.class).setUpstream(Suppliers.ofInstance(branch1.getObjectId()))
.call();
CheckoutResult result;
result = geogig.command(CheckoutOp.class).setSource("branch1").call();
assertEquals(c2.getTreeId(), result.getNewTree());
assertTrue(geogig.command(RefParse.class).setName(Ref.HEAD).call().get() instanceof SymRef);
assertEquals(branch1.getName(), ((SymRef) geogig.command(RefParse.class).setName(Ref.HEAD)
.call().get()).getTarget());
result = geogig.command(CheckoutOp.class).setSource("branch2").call();
assertFalse(c4.getTreeId().equals(result.getNewTree()));
assertTrue(geogig.command(RefParse.class).setName(Ref.HEAD).call().get() instanceof SymRef);