Class DirCacheBuildIterator


public class DirCacheBuildIterator extends DirCacheIterator
Iterate and update a DirCache as part of a TreeWalk.

Like DirCacheIterator this iterator allows a DirCache to be used in parallel with other sorts of iterators in a TreeWalk. However any entry which appears in the source DirCache and which is skipped by the TreeFilter is automatically copied into DirCacheBuilder, thus retaining it in the newly updated index.

This iterator is suitable for update processes, or even a simple delete algorithm. For example deleting a path:

 final DirCache dirc = db.lockDirCache();
 final DirCacheBuilder edit = dirc.builder();

 final TreeWalk walk = new TreeWalk(db);
 walk.reset();
 walk.setRecursive(true);
 walk.setFilter(PathFilter.create("name/to/remove"));
 walk.addTree(new DirCacheBuildIterator(edit));

 while (walk.next())
        ; // do nothing on a match as we want to remove matches
 edit.commit();