@Test
public void testTrivialTwoWay_validSubtreeSort() throws Exception {
- final DirCache treeB = db.readDirCache();
- final DirCache treeO = db.readDirCache();
- final DirCache treeT = db.readDirCache();
- {
- final DirCacheBuilder b = treeB.builder();
- final DirCacheBuilder o = treeO.builder();
- final DirCacheBuilder t = treeT.builder();
-
- b.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
- b.add(createEntry("libelf/c", FileMode.REGULAR_FILE));
-
- o.add(createEntry("Makefile", FileMode.REGULAR_FILE));
- o.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
- o.add(createEntry("libelf/c", FileMode.REGULAR_FILE));
-
- t.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
- t.add(createEntry("libelf/c", FileMode.REGULAR_FILE, "blah"));
-
- b.finish();
- o.finish();
- t.finish();
- }
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
+
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
+
+ bTreeBuilder.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("libelf/c", FileMode.REGULAR_FILE));
+
+ oTreeBuilder.add(createEntry("Makefile", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("libelf/c", FileMode.REGULAR_FILE));
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ tTreeBuilder.add(createEntry("libelf-po/a", FileMode.REGULAR_FILE));
+ tTreeBuilder
+ .add(createEntry("libelf/c", FileMode.REGULAR_FILE, "blah"));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
+
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@Test
public void testTrivialTwoWay_concurrentSubtreeChange() throws Exception {
- final DirCache treeB = db.readDirCache();
- final DirCache treeO = db.readDirCache();
- final DirCache treeT = db.readDirCache();
- {
- final DirCacheBuilder b = treeB.builder();
- final DirCacheBuilder o = treeO.builder();
- final DirCacheBuilder t = treeT.builder();
-
- b.add(createEntry("d/o", FileMode.REGULAR_FILE));
- b.add(createEntry("d/t", FileMode.REGULAR_FILE));
-
- o.add(createEntry("d/o", FileMode.REGULAR_FILE, "o !"));
- o.add(createEntry("d/t", FileMode.REGULAR_FILE));
-
- t.add(createEntry("d/o", FileMode.REGULAR_FILE));
- t.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
-
- b.finish();
- o.finish();
- t.finish();
- }
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
+
+ bTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE));
+
+ oTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE, "o !"));
+ oTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE));
+
+ tTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ tTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
+
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@Test
public void testTrivialTwoWay_conflictSubtreeChange() throws Exception {
- final DirCache treeB = db.readDirCache();
- final DirCache treeO = db.readDirCache();
- final DirCache treeT = db.readDirCache();
- {
- final DirCacheBuilder b = treeB.builder();
- final DirCacheBuilder o = treeO.builder();
- final DirCacheBuilder t = treeT.builder();
-
- b.add(createEntry("d/o", FileMode.REGULAR_FILE));
- b.add(createEntry("d/t", FileMode.REGULAR_FILE));
-
- o.add(createEntry("d/o", FileMode.REGULAR_FILE));
- o.add(createEntry("d/t", FileMode.REGULAR_FILE, "o !"));
-
- t.add(createEntry("d/o", FileMode.REGULAR_FILE, "t !"));
- t.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
-
- b.finish();
- o.finish();
- t.finish();
- }
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
+
+ bTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE));
+
+ oTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE, "o !"));
+
+ tTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE, "t !"));
+ tTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
+
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@Test
public void testTrivialTwoWay_leftDFconflict1() throws Exception {
- final DirCache treeB = db.readDirCache();
- final DirCache treeO = db.readDirCache();
- final DirCache treeT = db.readDirCache();
- {
- final DirCacheBuilder b = treeB.builder();
- final DirCacheBuilder o = treeO.builder();
- final DirCacheBuilder t = treeT.builder();
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- b.add(createEntry("d/o", FileMode.REGULAR_FILE));
- b.add(createEntry("d/t", FileMode.REGULAR_FILE));
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
- o.add(createEntry("d", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE));
- t.add(createEntry("d/o", FileMode.REGULAR_FILE));
- t.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
+ oTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE));
- b.finish();
- o.finish();
- t.finish();
- }
+ tTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ tTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE, "t !"));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@Test
public void testTrivialTwoWay_rightDFconflict1() throws Exception {
- final DirCache treeB = db.readDirCache();
- final DirCache treeO = db.readDirCache();
- final DirCache treeT = db.readDirCache();
- {
- final DirCacheBuilder b = treeB.builder();
- final DirCacheBuilder o = treeO.builder();
- final DirCacheBuilder t = treeT.builder();
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- b.add(createEntry("d/o", FileMode.REGULAR_FILE));
- b.add(createEntry("d/t", FileMode.REGULAR_FILE));
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
- o.add(createEntry("d/o", FileMode.REGULAR_FILE));
- o.add(createEntry("d/t", FileMode.REGULAR_FILE, "o !"));
+ bTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE));
- t.add(createEntry("d", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("d/t", FileMode.REGULAR_FILE, "o !"));
- b.finish();
- o.finish();
- t.finish();
- }
+ tTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@Test
public void testTrivialTwoWay_leftDFconflict2() throws Exception {
- final DirCache treeB = db.readDirCache();
- final DirCache treeO = db.readDirCache();
- final DirCache treeT = db.readDirCache();
- {
- final DirCacheBuilder b = treeB.builder();
- final DirCacheBuilder o = treeO.builder();
- final DirCacheBuilder t = treeT.builder();
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- b.add(createEntry("d", FileMode.REGULAR_FILE));
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
- o.add(createEntry("d", FileMode.REGULAR_FILE, "o !"));
+ bTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE));
- t.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ oTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE, "o !"));
- b.finish();
- o.finish();
- t.finish();
- }
+ tTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
+
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
@Test
public void testTrivialTwoWay_rightDFconflict2() throws Exception {
- final DirCache treeB = db.readDirCache();
- final DirCache treeO = db.readDirCache();
- final DirCache treeT = db.readDirCache();
- {
- final DirCacheBuilder b = treeB.builder();
- final DirCacheBuilder o = treeO.builder();
- final DirCacheBuilder t = treeT.builder();
+ DirCache treeB = db.readDirCache();
+ DirCache treeO = db.readDirCache();
+ DirCache treeT = db.readDirCache();
- b.add(createEntry("d", FileMode.REGULAR_FILE));
+ DirCacheBuilder bTreeBuilder = treeB.builder();
+ DirCacheBuilder oTreeBuilder = treeO.builder();
+ DirCacheBuilder tTreeBuilder = treeT.builder();
- o.add(createEntry("d/o", FileMode.REGULAR_FILE));
+ bTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE));
- t.add(createEntry("d", FileMode.REGULAR_FILE, "t !"));
+ oTreeBuilder.add(createEntry("d/o", FileMode.REGULAR_FILE));
- b.finish();
- o.finish();
- t.finish();
- }
+ tTreeBuilder.add(createEntry("d", FileMode.REGULAR_FILE, "t !"));
+
+ bTreeBuilder.finish();
+ oTreeBuilder.finish();
+ tTreeBuilder.finish();
- final ObjectInserter ow = db.newObjectInserter();
- final ObjectId b = commit(ow, treeB, new ObjectId[] {});
- final ObjectId o = commit(ow, treeO, new ObjectId[] { b });
- final ObjectId t = commit(ow, treeT, new ObjectId[] { b });
+ ObjectInserter ow = db.newObjectInserter();
+ ObjectId b = commit(ow, treeB, new ObjectId[] {});
+ ObjectId o = commit(ow, treeO, new ObjectId[] { b });
+ ObjectId t = commit(ow, treeT, new ObjectId[] { b });
Merger ourMerger = MergeStrategy.SIMPLE_TWO_WAY_IN_CORE.newMerger(db);
boolean merge = ourMerger.merge(new ObjectId[] { o, t });
.getObjectId(0));
}
- private static ObjectId commit(final ObjectInserter odi,
- final DirCache treeB,
- final ObjectId[] parentIds) throws Exception {
- final CommitBuilder c = new CommitBuilder();
+ private static ObjectId commit(ObjectInserter odi, DirCache treeB,
+ ObjectId[] parentIds) throws Exception {
+ CommitBuilder c = new CommitBuilder();
c.setTreeId(treeB.writeTree(odi));
c.setAuthor(new PersonIdent("A U Thor", "a.u.thor", 1L, 0));
c.setCommitter(c.getAuthor());