Add writeTree support to DirCache
commit3aa89e4a6952c2e3517d9abac0b4598c3278cddd
authorShawn O. Pearce <spearce@spearce.org>
Thu, 22 Jan 2009 23:28:04 +0000 (22 15:28 -0800)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Fri, 23 Jan 2009 22:27:18 +0000 (23 23:27 +0100)
tree95e33d03b8828d8c933073610a6fc6bffa6d0f81
parent26c98cad28009af6861d5f9695181f7cc876cf1b
Add writeTree support to DirCache

This way we can write a full tree from the DirCache, including reusing
any valid tree entries stored within the 'TREE' cache extension.  By
reusing those entries we can avoid generating the tree objects that
are already stored in the Git repository.

The algorithm may cause up to 3 passes over the DirCache entries:

 * Pass 1: Compute the tree structure
 * Pass 2: Compute the sizes of each tree
 * Pass 3: Write the tree object to the object store

These extra passes cause more CPU time to be expended in exchange
for a lower memory requirement during the tree writing.  The code
is only formatting the lowest level leaf tree which has not yet
been written to the object store, so higher level trees do not
occupy memory while they are waiting for the leaves to write out.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.spearce.jgit/src/org/spearce/jgit/dircache/DirCache.java
org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheTree.java
org.spearce.jgit/src/org/spearce/jgit/errors/UnmergedPathException.java [new file with mode: 0644]
org.spearce.jgit/src/org/spearce/jgit/lib/FileMode.java
org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java