@ -46,6 +46,8 @@
package org.eclipse.jgit.lib ;
import java.io.IOException ;
import java.util.ArrayList ;
import java.util.Collection ;
import java.util.HashSet ;
import org.eclipse.jgit.dircache.DirCache ;
@ -84,6 +86,8 @@ public class IndexDiff {
private final RevTree tree ;
private TreeFilter filter = null ;
private final WorkingTreeIterator initialWorkingTreeIterator ;
private HashSet < String > added = new HashSet < String > ( ) ;
@ -140,6 +144,15 @@ public class IndexDiff {
this . initialWorkingTreeIterator = workingTreeIterator ;
}
/ * *
* Sets a filter . Can be used e . g . for restricting the tree walk to a set of
* files .
*
* @param filter
* /
public void setFilter ( TreeFilter filter ) {
this . filter = filter ;
}
/ * *
* Run the diff operation . Until this is called , all lists will be empty
@ -160,10 +173,14 @@ public class IndexDiff {
treeWalk . addTree ( new EmptyTreeIterator ( ) ) ;
treeWalk . addTree ( new DirCacheIterator ( dirCache ) ) ;
treeWalk . addTree ( initialWorkingTreeIterator ) ;
treeWalk . setFilter ( TreeFilter . ANY_DIFF ) ;
treeWalk . setFilter ( AndTreeFilter . create ( new TreeFilter [ ] {
new NotIgnoredFilter ( WORKDIR ) , new SkipWorkTreeFilter ( INDEX ) ,
TreeFilter . ANY_DIFF } ) ) ;
Collection < TreeFilter > filters = new ArrayList < TreeFilter > (
filter = = null ? 3 : 4 ) ;
if ( filter ! = null )
filters . add ( filter ) ;
filters . add ( new NotIgnoredFilter ( WORKDIR ) ) ;
filters . add ( new SkipWorkTreeFilter ( INDEX ) ) ;
filters . add ( TreeFilter . ANY_DIFF ) ;
treeWalk . setFilter ( AndTreeFilter . create ( filters ) ) ;
while ( treeWalk . next ( ) ) {
AbstractTreeIterator treeIterator = treeWalk . getTree ( TREE ,
AbstractTreeIterator . class ) ;