diff options
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit')
9 files changed, 124 insertions, 72 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java index c439baccf6..3d19576758 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/IndexDiffTest.java @@ -56,7 +56,7 @@ public class IndexDiffTest extends RepositoryTestCase { writeTrashFile("file1", "file1"); writeTrashFile("dir/subfile", "dir/subfile"); Tree tree = new Tree(db); - tree.setId(new ObjectWriter(db).writeTree(tree)); + tree.setId(insertTree(tree)); index.add(trash, new File(trash, "file1")); index.add(trash, new File(trash, "dir/subfile")); @@ -83,8 +83,8 @@ public class IndexDiffTest extends RepositoryTestCase { tree.findBlobMember("file2").setId(ObjectId.fromString("30d67d4672d5c05833b7192cc77a79eaafb5c7ad")); Tree tree2 = (Tree) tree.findTreeMember("dir"); tree2.findBlobMember("file3").setId(ObjectId.fromString("873fb8d667d05436d728c52b1d7a09528e6eb59b")); - tree2.setId(new ObjectWriter(db).writeTree(tree2)); - tree.setId(new ObjectWriter(db).writeTree(tree)); + tree2.setId(insertTree(tree2)); + tree.setId(insertTree(tree)); FileTreeIterator iterator = new FileTreeIterator(db); IndexDiff diff = new IndexDiff(db, tree.getId(), iterator); @@ -113,8 +113,8 @@ public class IndexDiffTest extends RepositoryTestCase { assertEquals(2, tree.memberCount()); Tree tree2 = (Tree) tree.findTreeMember("dir"); - tree2.setId(new ObjectWriter(db).writeTree(tree2)); - tree.setId(new ObjectWriter(db).writeTree(tree)); + tree2.setId(insertTree(tree2)); + tree.setId(insertTree(tree)); FileTreeIterator iterator = new FileTreeIterator(db); IndexDiff diff = new IndexDiff(db, tree.getId(), iterator); diff.diff(); @@ -144,7 +144,7 @@ public class IndexDiffTest extends RepositoryTestCase { tree.addFile("a=c").setId(ObjectId.fromString("06022365ddbd7fb126761319633bf73517770714")); tree.addFile("a=d").setId(ObjectId.fromString("fa6414df3da87840700e9eeb7fc261dd77ccd5c2")); - tree.setId(new ObjectWriter(db).writeTree(tree)); + tree.setId(insertTree(tree)); FileTreeIterator iterator = new FileTreeIterator(db); IndexDiff diff = new IndexDiff(db, tree.getId(), iterator); @@ -185,10 +185,10 @@ public class IndexDiffTest extends RepositoryTestCase { tree.addFile("a=d").setId(ObjectId.fromString("fa6414df3da87840700e9eeb7fc261dd77ccd5c2")); Tree tree3 = (Tree) tree.findTreeMember("a/b.b"); - tree3.setId(new ObjectWriter(db).writeTree(tree3)); + tree3.setId(insertTree(tree3)); Tree tree2 = (Tree) tree.findTreeMember("a"); - tree2.setId(new ObjectWriter(db).writeTree(tree2)); - tree.setId(new ObjectWriter(db).writeTree(tree)); + tree2.setId(insertTree(tree2)); + tree.setId(insertTree(tree)); FileTreeIterator iterator = new FileTreeIterator(db); IndexDiff diff = new IndexDiff(db, tree.getId(), iterator); @@ -199,4 +199,15 @@ public class IndexDiffTest extends RepositoryTestCase { assertEquals(0, diff.getMissing().size()); assertEquals(0, diff.getModified().size()); } + + private ObjectId insertTree(Tree tree) throws IOException { + ObjectInserter oi = db.newObjectInserter(); + try { + ObjectId id = oi.insert(Constants.OBJ_TREE, tree.format()); + oi.flush(); + return id; + } finally { + oi.release(); + } + } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReadTreeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReadTreeTest.java index fe2d0b248c..f2bb66fd30 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReadTreeTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReadTreeTest.java @@ -110,21 +110,25 @@ public abstract class ReadTreeTest extends RepositoryTestCase { private Tree buildTree(HashMap<String, String> headEntries) throws IOException { Tree tree = new Tree(db); - ObjectWriter ow = new ObjectWriter(db); if (headEntries == null) return tree; FileTreeEntry fileEntry; Tree parent; - for (java.util.Map.Entry<String, String> e : headEntries.entrySet()) { - fileEntry = tree.addFile(e.getKey()); - fileEntry.setId(genSha1(e.getValue())); - parent = fileEntry.getParent(); - while (parent != null) { - parent.setId(ow.writeTree(parent)); - parent = parent.getParent(); + ObjectInserter oi = db.newObjectInserter(); + try { + for (java.util.Map.Entry<String, String> e : headEntries.entrySet()) { + fileEntry = tree.addFile(e.getKey()); + fileEntry.setId(genSha1(e.getValue())); + parent = fileEntry.getParent(); + while (parent != null) { + parent.setId(oi.insert(Constants.OBJ_TREE, parent.format())); + parent = parent.getParent(); + } } + oi.flush(); + } finally { + oi.release(); } - return tree; } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogConfigTest.java index ebe2db111d..92c4b9cc04 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogConfigTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogConfigTest.java @@ -109,8 +109,13 @@ public class ReflogConfigTest extends RepositoryTestCase { commit.setCommitter(committer); commit.setMessage(commitMsg); commit.setTreeId(t.getTreeId()); - ObjectWriter writer = new ObjectWriter(db); - commit.setCommitId(writer.writeCommit(commit)); + ObjectInserter inserter = db.newObjectInserter(); + try { + inserter.insert(commit); + inserter.flush(); + } finally { + inserter.release(); + } int nl = commitMsg.indexOf('\n'); final RefUpdate ru = db.updateRef(Constants.HEAD); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ObjectWalkTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ObjectWalkTest.java index 0ff4d512e8..840bee8466 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ObjectWalkTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/ObjectWalkTest.java @@ -43,9 +43,10 @@ package org.eclipse.jgit.revwalk; +import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.FileTreeEntry; import org.eclipse.jgit.lib.ObjectId; -import org.eclipse.jgit.lib.ObjectWriter; +import org.eclipse.jgit.lib.ObjectInserter; import org.eclipse.jgit.lib.Tree; public class ObjectWalkTest extends RevWalkTestCase { @@ -214,11 +215,16 @@ public class ObjectWalkTest extends RevWalkTestCase { Tree A_A = A.addTree("A"); Tree A_B = A.addTree("B"); - final ObjectWriter ow = new ObjectWriter(db); - A_A.setId(ow.writeTree(A_A)); - A_B.setId(ow.writeTree(A_B)); - A.setId(ow.writeTree(A)); - root.setId(ow.writeTree(root)); + final ObjectInserter inserter = db.newObjectInserter(); + try { + A_A.setId(inserter.insert(Constants.OBJ_TREE, A_A.format())); + A_B.setId(inserter.insert(Constants.OBJ_TREE, A_B.format())); + A.setId(inserter.insert(Constants.OBJ_TREE, A.format())); + root.setId(inserter.insert(Constants.OBJ_TREE, root.format())); + inserter.flush(); + } finally { + inserter.release(); + } tree_root = rw.parseTree(root.getId()); tree_A = rw.parseTree(A.getId()); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/ConcurrentRepackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/ConcurrentRepackTest.java index c8f2aad759..7608a51f22 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/ConcurrentRepackTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/ConcurrentRepackTest.java @@ -57,8 +57,8 @@ import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.lib.ObjectInserter; import org.eclipse.jgit.lib.ObjectLoader; -import org.eclipse.jgit.lib.ObjectWriter; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.RepositoryTestCase; import org.eclipse.jgit.revwalk.RevObject; @@ -265,8 +265,14 @@ public class ConcurrentRepackTest extends RepositoryTestCase { throws IOException { final RevWalk revWalk = new RevWalk(repo); final byte[] bytes = Constants.encode(data); - final ObjectWriter ow = new ObjectWriter(repo); - final ObjectId id = ow.writeBlob(bytes); + final ObjectInserter inserter = repo.newObjectInserter(); + final ObjectId id; + try { + id = inserter.insert(Constants.OBJ_BLOB, bytes); + inserter.flush(); + } finally { + inserter.release(); + } try { parse(id); fail("Object " + id.name() + " should not exist in test repository"); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_Basic.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_Basic.java index 0352a40bfd..baa35f274b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_Basic.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/T0003_Basic.java @@ -46,7 +46,6 @@ package org.eclipse.jgit.storage.file; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileReader; @@ -67,7 +66,6 @@ import org.eclipse.jgit.lib.FileTreeEntry; import org.eclipse.jgit.lib.ObjectDatabase; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectInserter; -import org.eclipse.jgit.lib.ObjectWriter; import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.RefUpdate; import org.eclipse.jgit.lib.Repository; @@ -294,7 +292,7 @@ public class T0003_Basic extends SampleDataRepositoryTestCase { public void test003_WriteShouldBeEmptyTree() throws IOException { final Tree t = new Tree(db); - final ObjectId emptyId = new ObjectWriter(db).writeBlob(new byte[0]); + final ObjectId emptyId = insertEmptyBlob(); t.addFile("should-be-empty").setId(emptyId); t.accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY); assertEquals("7bb943559a305bdd6bdee2cef6e5df2413c3d30a", t.getId() @@ -419,7 +417,7 @@ public class T0003_Basic extends SampleDataRepositoryTestCase { } public void test012_SubtreeExternalSorting() throws IOException { - final ObjectId emptyBlob = new ObjectWriter(db).writeBlob(new byte[0]); + final ObjectId emptyBlob = insertEmptyBlob(); final Tree t = new Tree(db); final FileTreeEntry e0 = t.addFile("a-"); final FileTreeEntry e1 = t.addFile("a-b"); @@ -439,7 +437,7 @@ public class T0003_Basic extends SampleDataRepositoryTestCase { } public void test020_createBlobTag() throws IOException { - final ObjectId emptyId = new ObjectWriter(db).writeBlob(new byte[0]); + final ObjectId emptyId = insertEmptyBlob(); final TagBuilder t = new TagBuilder(); t.setObjectId(emptyId, Constants.OBJ_BLOB); t.setTag("test020"); @@ -456,10 +454,10 @@ public class T0003_Basic extends SampleDataRepositoryTestCase { } public void test021_createTreeTag() throws IOException { - final ObjectId emptyId = new ObjectWriter(db).writeBlob(new byte[0]); + final ObjectId emptyId = insertEmptyBlob(); final Tree almostEmptyTree = new Tree(db); almostEmptyTree.addEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false)); - final ObjectId almostEmptyTreeId = new ObjectWriter(db).writeTree(almostEmptyTree); + final ObjectId almostEmptyTreeId = insertTree(almostEmptyTree); final TagBuilder t = new TagBuilder(); t.setObjectId(almostEmptyTreeId, Constants.OBJ_TREE); t.setTag("test021"); @@ -476,10 +474,10 @@ public class T0003_Basic extends SampleDataRepositoryTestCase { } public void test022_createCommitTag() throws IOException { - final ObjectId emptyId = new ObjectWriter(db).writeBlob(new byte[0]); + final ObjectId emptyId = insertEmptyBlob(); final Tree almostEmptyTree = new Tree(db); almostEmptyTree.addEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false)); - final ObjectId almostEmptyTreeId = new ObjectWriter(db).writeTree(almostEmptyTree); + final ObjectId almostEmptyTreeId = insertTree(almostEmptyTree); final CommitBuilder almostEmptyCommit = new CommitBuilder(); almostEmptyCommit.setAuthor(new PersonIdent(author, 1154236443000L, -2 * 60)); // not exactly the same almostEmptyCommit.setCommitter(new PersonIdent(author, 1154236443000L, -2 * 60)); @@ -502,10 +500,10 @@ public class T0003_Basic extends SampleDataRepositoryTestCase { } public void test023_createCommitNonAnullii() throws IOException { - final ObjectId emptyId = new ObjectWriter(db).writeBlob(new byte[0]); + final ObjectId emptyId = insertEmptyBlob(); final Tree almostEmptyTree = new Tree(db); almostEmptyTree.addEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false)); - final ObjectId almostEmptyTreeId = new ObjectWriter(db).writeTree(almostEmptyTree); + final ObjectId almostEmptyTreeId = insertTree(almostEmptyTree); CommitBuilder commit = new CommitBuilder(); commit.setTreeId(almostEmptyTreeId); commit.setAuthor(new PersonIdent("Joe H\u00e4cker","joe@example.com",4294967295000L,60)); @@ -520,10 +518,10 @@ public class T0003_Basic extends SampleDataRepositoryTestCase { } public void test024_createCommitNonAscii() throws IOException { - final ObjectId emptyId = new ObjectWriter(db).writeBlob(new byte[0]); + final ObjectId emptyId = insertEmptyBlob(); final Tree almostEmptyTree = new Tree(db); almostEmptyTree.addEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false)); - final ObjectId almostEmptyTreeId = new ObjectWriter(db).writeTree(almostEmptyTree); + final ObjectId almostEmptyTreeId = insertTree(almostEmptyTree); CommitBuilder commit = new CommitBuilder(); commit.setTreeId(almostEmptyTreeId); commit.setAuthor(new PersonIdent("Joe H\u00e4cker","joe@example.com",4294967295000L,60)); @@ -537,9 +535,8 @@ public class T0003_Basic extends SampleDataRepositoryTestCase { public void test025_computeSha1NoStore() throws IOException { byte[] data = "test025 some data, more than 16 bytes to get good coverage" .getBytes("ISO-8859-1"); - // TODO: but we do not test legacy header writing - final ObjectId id = new ObjectWriter(db).computeBlobSha1(data.length, - new ByteArrayInputStream(data)); + final ObjectId id = new ObjectInserter.Formatter().idFor( + Constants.OBJ_BLOB, data); assertEquals("4f561df5ecf0dfbd53a0dc0f37262fef075d9dde", id.name()); } @@ -693,6 +690,29 @@ public class T0003_Basic extends SampleDataRepositoryTestCase { } + private ObjectId insertEmptyBlob() throws IOException { + final ObjectId emptyId; + ObjectInserter oi = db.newObjectInserter(); + try { + emptyId = oi.insert(Constants.OBJ_BLOB, new byte[] {}); + oi.flush(); + } finally { + oi.release(); + } + return emptyId; + } + + private ObjectId insertTree(Tree tree) throws IOException { + ObjectInserter oi = db.newObjectInserter(); + try { + ObjectId id = oi.insert(Constants.OBJ_TREE, tree.format()); + oi.flush(); + return id; + } finally { + oi.release(); + } + } + private ObjectId insertCommit(final CommitBuilder builder) throws IOException, UnsupportedEncodingException { ObjectInserter oi = db.newObjectInserter(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/NameConflictTreeWalkTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/NameConflictTreeWalkTest.java index e59b7c18d3..7e3dea6714 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/NameConflictTreeWalkTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/NameConflictTreeWalkTest.java @@ -43,15 +43,13 @@ package org.eclipse.jgit.treewalk; -import java.io.ByteArrayInputStream; - import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheBuilder; import org.eclipse.jgit.dircache.DirCacheEntry; import org.eclipse.jgit.dircache.DirCacheIterator; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.FileMode; -import org.eclipse.jgit.lib.ObjectWriter; +import org.eclipse.jgit.lib.ObjectInserter; import org.eclipse.jgit.lib.RepositoryTestCase; public class NameConflictTreeWalkTest extends RepositoryTestCase { @@ -248,11 +246,10 @@ public class NameConflictTreeWalkTest extends RepositoryTestCase { private DirCacheEntry makeEntry(final String path, final FileMode mode) throws Exception { - final byte[] pathBytes = Constants.encode(path); final DirCacheEntry ent = new DirCacheEntry(path); ent.setFileMode(mode); - ent.setObjectId(new ObjectWriter(db).computeBlobSha1(pathBytes.length, - new ByteArrayInputStream(pathBytes))); + ent.setObjectId(new ObjectInserter.Formatter().idFor( + Constants.OBJ_BLOB, Constants.encode(path))); return ent; } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/PostOrderTreeWalkTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/PostOrderTreeWalkTest.java index 274df5bec0..8f813a806b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/PostOrderTreeWalkTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/PostOrderTreeWalkTest.java @@ -43,7 +43,8 @@ package org.eclipse.jgit.treewalk; -import java.io.ByteArrayInputStream; +import static org.eclipse.jgit.lib.FileMode.REGULAR_FILE; +import static org.eclipse.jgit.lib.FileMode.TREE; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheBuilder; @@ -51,12 +52,9 @@ import org.eclipse.jgit.dircache.DirCacheEntry; import org.eclipse.jgit.dircache.DirCacheIterator; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.FileMode; -import org.eclipse.jgit.lib.ObjectWriter; +import org.eclipse.jgit.lib.ObjectInserter; import org.eclipse.jgit.lib.RepositoryTestCase; -import static org.eclipse.jgit.lib.FileMode.REGULAR_FILE; -import static org.eclipse.jgit.lib.FileMode.TREE; - public class PostOrderTreeWalkTest extends RepositoryTestCase { public void testInitialize_NoPostOrder() throws Exception { final TreeWalk tw = new TreeWalk(db); @@ -178,11 +176,10 @@ public class PostOrderTreeWalkTest extends RepositoryTestCase { } private DirCacheEntry makeFile(final String path) throws Exception { - final byte[] pathBytes = Constants.encode(path); final DirCacheEntry ent = new DirCacheEntry(path); ent.setFileMode(REGULAR_FILE); - ent.setObjectId(new ObjectWriter(db).computeBlobSha1(pathBytes.length, - new ByteArrayInputStream(pathBytes))); + ent.setObjectId(new ObjectInserter.Formatter().idFor( + Constants.OBJ_BLOB, Constants.encode(path))); return ent; } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/TreeWalkBasicDiffTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/TreeWalkBasicDiffTest.java index 581683e34f..e0957401c5 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/TreeWalkBasicDiffTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/TreeWalkBasicDiffTest.java @@ -43,9 +43,13 @@ package org.eclipse.jgit.treewalk; +import static org.eclipse.jgit.lib.Constants.OBJ_BLOB; +import static org.eclipse.jgit.lib.Constants.OBJ_TREE; +import static org.eclipse.jgit.lib.Constants.encode; + import org.eclipse.jgit.lib.FileMode; import org.eclipse.jgit.lib.ObjectId; -import org.eclipse.jgit.lib.ObjectWriter; +import org.eclipse.jgit.lib.ObjectInserter; import org.eclipse.jgit.lib.RepositoryTestCase; import org.eclipse.jgit.lib.Tree; import org.eclipse.jgit.treewalk.filter.TreeFilter; @@ -53,11 +57,11 @@ import org.eclipse.jgit.treewalk.filter.TreeFilter; public class TreeWalkBasicDiffTest extends RepositoryTestCase { public void testMissingSubtree_DetectFileAdded_FileModified() throws Exception { - final ObjectWriter ow = new ObjectWriter(db); - final ObjectId aFileId = ow.writeBlob("a".getBytes()); - final ObjectId bFileId = ow.writeBlob("b".getBytes()); - final ObjectId cFileId1 = ow.writeBlob("c-1".getBytes()); - final ObjectId cFileId2 = ow.writeBlob("c-2".getBytes()); + final ObjectInserter inserter = db.newObjectInserter(); + final ObjectId aFileId = inserter.insert(OBJ_BLOB, encode("a")); + final ObjectId bFileId = inserter.insert(OBJ_BLOB, encode("b")); + final ObjectId cFileId1 = inserter.insert(OBJ_BLOB, encode("c-1")); + final ObjectId cFileId2 = inserter.insert(OBJ_BLOB, encode("c-2")); // Create sub-a/empty, sub-c/empty = hello. final ObjectId oldTree; @@ -66,14 +70,14 @@ public class TreeWalkBasicDiffTest extends RepositoryTestCase { { final Tree subA = root.addTree("sub-a"); subA.addFile("empty").setId(aFileId); - subA.setId(ow.writeTree(subA)); + subA.setId(inserter.insert(OBJ_TREE, subA.format())); } { final Tree subC = root.addTree("sub-c"); subC.addFile("empty").setId(cFileId1); - subC.setId(ow.writeTree(subC)); + subC.setId(inserter.insert(OBJ_TREE, subC.format())); } - oldTree = ow.writeTree(root); + oldTree = inserter.insert(OBJ_TREE, root.format()); } // Create sub-a/empty, sub-b/empty, sub-c/empty. @@ -83,20 +87,22 @@ public class TreeWalkBasicDiffTest extends RepositoryTestCase { { final Tree subA = root.addTree("sub-a"); subA.addFile("empty").setId(aFileId); - subA.setId(ow.writeTree(subA)); + subA.setId(inserter.insert(OBJ_TREE, subA.format())); } { final Tree subB = root.addTree("sub-b"); subB.addFile("empty").setId(bFileId); - subB.setId(ow.writeTree(subB)); + subB.setId(inserter.insert(OBJ_TREE, subB.format())); } { final Tree subC = root.addTree("sub-c"); subC.addFile("empty").setId(cFileId2); - subC.setId(ow.writeTree(subC)); + subC.setId(inserter.insert(OBJ_TREE, subC.format())); } - newTree = ow.writeTree(root); + newTree = inserter.insert(OBJ_TREE, root.format()); } + inserter.flush(); + inserter.release(); final TreeWalk tw = new TreeWalk(db); tw.reset(new ObjectId[] { oldTree, newTree }); |