@ -50,7 +50,6 @@ import java.util.Arrays;
import org.eclipse.jgit.JGitText ;
import org.eclipse.jgit.lib.AnyObjectId ;
import org.eclipse.jgit.lib.Repository ;
import org.eclipse.jgit.lib.ObjectReader ;
import org.eclipse.jgit.treewalk.AbstractTreeIterator ;
import org.eclipse.jgit.treewalk.CanonicalTreeParser ;
@ -149,11 +148,12 @@ public class DirCacheBuilder extends BaseDirCacheEditor {
* as necessary .
* @param stage
* stage of the entries when adding them .
* @param db
* repository the tree ( s ) will be read from during recursive
* @param reader
* reader the tree ( s ) will be read from during recursive
* traversal . This must be the same repository that the resulting
* DirCache would be written out to ( or used in ) otherwise the
* caller is simply asking for deferred MissingObjectExceptions .
* Caller is responsible for releasing this reader when done .
* @param tree
* the tree to recursively add . This tree ' s contents will appear
* under < code > pathPrefix < / code > . The ObjectId must be that of a
@ -163,23 +163,18 @@ public class DirCacheBuilder extends BaseDirCacheEditor {
* a tree cannot be read to iterate through its entries .
* /
public void addTree ( final byte [ ] pathPrefix , final int stage ,
final Repository db , final AnyObjectId tree ) throws IOException {
final ObjectReader reader = db . newObjectReader ( ) ;
try {
final TreeWalk tw = new TreeWalk ( reader ) ;
tw . reset ( ) ;
tw . addTree ( new CanonicalTreeParser ( pathPrefix , reader , tree
. toObjectId ( ) ) ) ;
tw . setRecursive ( true ) ;
if ( tw . next ( ) ) {
final DirCacheEntry newEntry = toEntry ( stage , tw ) ;
beforeAdd ( newEntry ) ;
fastAdd ( newEntry ) ;
while ( tw . next ( ) )
fastAdd ( toEntry ( stage , tw ) ) ;
}
} finally {
reader . release ( ) ;
final ObjectReader reader , final AnyObjectId tree ) throws IOException {
final TreeWalk tw = new TreeWalk ( reader ) ;
tw . reset ( ) ;
tw . addTree ( new CanonicalTreeParser ( pathPrefix , reader , tree
. toObjectId ( ) ) ) ;
tw . setRecursive ( true ) ;
if ( tw . next ( ) ) {
final DirCacheEntry newEntry = toEntry ( stage , tw ) ;
beforeAdd ( newEntry ) ;
fastAdd ( newEntry ) ;
while ( tw . next ( ) )
fastAdd ( toEntry ( stage , tw ) ) ;
}
}