Support the 'TREE' extension in .git/index through DirCache
commit4e391d43aa814cede5c01c9ef710f819d4683475
authorShawn O. Pearce <spearce@spearce.org>
Tue, 12 Aug 2008 01:07:57 +0000 (11 18:07 -0700)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Thu, 14 Aug 2008 17:33:20 +0000 (14 19:33 +0200)
tree16f79d78800118e68132984356305bac52ccaa40
parentb363a982a6f06011f963bbe4d1881603a781ac5e
Support the 'TREE' extension in .git/index through DirCache

We now support reading and writing the 'TREE' extension of the 'DIRC'
file format.  C Git uses this as an optional extension to cache the
SHA-1 id of each tree object used by the index, permitting C Git to
identify subsections of the repository which have not been modified
and to speed up the git-write-tree plumbing command prior to making
a commit object.

Our support includes constructing the tree objects if they do not
exist, but we don't write them to the object database.  This change
only builds the ranges within the index file and marks them invalid,
so C Git knows that the tree must be generated and saved into the
object database before it can rely upon it in a commit.

Like the DirCacheEntry objects we try to avoid unnecessary encode
and decode operations during reads and writes as they would just
drag down the processor.

Our sort ordering of the 'TREE' data is different from that of C Git.
C Git sorts tree children according to lengths of path names, as the
actual order was not relevant but Junio wanted a stable ordering.  We
want our tree children sorted by name so we can merge-sort them onto
the main index entries.  That means we may have to sort the children
after we read them from disk; at least that is true if C Git was the
last process to write the index file.

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 [new file with mode: 0644]