// |
// o - Points 3 added
// |
// o - branch2 - HEAD - Lines 1 added
insertAndAdd(points1);
final RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
// create branch1 and checkout
geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch1").call();
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);
assertEquals(branch2.getName(), ((SymRef) geogig.command(RefParse.class).setName(Ref.HEAD)
.call().get()).getTarget());
Iterator<RevCommit> log = geogig.command(LogOp.class).call();
// Commit 4
RevCommit logC4 = log.next();
assertEquals(c4.getAuthor(), logC4.getAuthor());
assertEquals(c4.getCommitter().getName(), logC4.getCommitter().getName());
assertEquals(c4.getCommitter().getEmail(), logC4.getCommitter().getEmail());
assertEquals(c4.getMessage(), logC4.getMessage());
assertEquals(c4.getAuthor().getTimeZoneOffset(), logC4.getAuthor().getTimeZoneOffset());
assertEquals(c4.getAuthor().getTimestamp(), logC4.getAuthor().getTimestamp());
assertEquals(c4.getCommitter().getTimeZoneOffset(), logC4.getCommitter()
.getTimeZoneOffset());
assertFalse(c4.getCommitter().getTimestamp() == logC4.getCommitter().getTimestamp());
assertFalse(c4.getTreeId().equals(logC4.getTreeId()));
// Commit 3
RevCommit logC3 = log.next();
assertEquals(c3.getAuthor(), logC3.getAuthor());
assertEquals(c3.getCommitter().getName(), logC3.getCommitter().getName());
assertEquals(c3.getCommitter().getEmail(), logC3.getCommitter().getEmail());
assertEquals(c3.getMessage(), logC3.getMessage());
assertEquals(c3.getAuthor().getTimeZoneOffset(), logC3.getAuthor().getTimeZoneOffset());
assertEquals(c3.getAuthor().getTimestamp(), logC3.getAuthor().getTimestamp());
assertEquals(c3.getCommitter().getTimeZoneOffset(), logC3.getCommitter()
.getTimeZoneOffset());
assertFalse(c3.getCommitter().getTimestamp() == logC3.getCommitter().getTimestamp());
assertFalse(c3.getTreeId().equals(logC3.getTreeId()));
// Commit 2
RevCommit logC2 = log.next();
assertEquals(c2.getAuthor(), logC2.getAuthor());
assertEquals(c2.getCommitter().getName(), logC2.getCommitter().getName());
assertEquals(c2.getMessage(), logC2.getMessage());
assertEquals(c2.getAuthor().getTimeZoneOffset(), logC2.getAuthor().getTimeZoneOffset());
assertEquals(c2.getAuthor().getTimestamp(), logC2.getAuthor().getTimestamp());
assertEquals(c2.getCommitter().getTimeZoneOffset(), logC2.getCommitter()
.getTimeZoneOffset());
assertEquals(c2.getCommitter().getTimestamp(), logC2.getCommitter().getTimestamp());
assertEquals(c2.getTreeId(), logC2.getTreeId());
// Commit 1
RevCommit logC1 = log.next();
assertEquals(c1.getAuthor(), logC1.getAuthor());
assertEquals(c1.getCommitter().getName(), logC1.getCommitter().getName());
assertEquals(c1.getMessage(), logC1.getMessage());
assertEquals(c1.getAuthor().getTimeZoneOffset(), logC1.getAuthor().getTimeZoneOffset());
assertEquals(c1.getAuthor().getTimestamp(), logC1.getAuthor().getTimestamp());
assertEquals(c1.getCommitter().getTimeZoneOffset(), logC1.getCommitter()
.getTimeZoneOffset());
assertEquals(c1.getCommitter().getTimestamp(), logC1.getCommitter().getTimestamp());
assertEquals(c1.getTreeId(), logC1.getTreeId());
}