@ -43,6 +43,8 @@
package org.eclipse.jgit.treewalk.filter ;
import java.io.IOException ;
import java.util.HashSet ;
import java.util.Set ;
import org.eclipse.jgit.dircache.DirCacheIterator ;
import org.eclipse.jgit.errors.IncorrectObjectTypeException ;
@ -79,6 +81,8 @@ public class IndexDiffFilter extends TreeFilter {
private final boolean honorIgnores ;
private final Set < String > ignoredPaths = new HashSet < String > ( ) ;
/ * *
* Creates a new instance of this filter . Do not use an instance of this
* filter in multiple treewalks .
@ -129,8 +133,10 @@ public class IndexDiffFilter extends TreeFilter {
// other tree.
final int cnt = tw . getTreeCount ( ) ;
final int dm = tw . getRawMode ( dirCache ) ;
WorkingTreeIterator wi = workingTree ( tw ) ;
if ( dm = = 0 ) {
if ( honorIgnores & & workingTree ( tw ) . isEntryIgnored ( ) ) {
if ( honorIgnores & & wi . isEntryIgnored ( ) ) {
ignoredPaths . add ( wi . getEntryPathString ( ) ) ;
int i = 0 ;
for ( ; i < cnt ; i + + ) {
if ( i = = dirCache | | i = = workingTree )
@ -166,7 +172,6 @@ public class IndexDiffFilter extends TreeFilter {
// Only one chance left to detect a diff: between index and working
// tree. Make use of the WorkingTreeIterator#isModified() method to
// avoid computing SHA1 on filesystem content if not really needed.
WorkingTreeIterator wi = workingTree ( tw ) ;
DirCacheIterator di = tw . getTree ( dirCache , DirCacheIterator . class ) ;
return wi . isModified ( di . getDirCacheEntry ( ) , true ) ;
}
@ -191,4 +196,17 @@ public class IndexDiffFilter extends TreeFilter {
public String toString ( ) {
return "INDEX_DIFF_FILTER" ;
}
/ * *
* The method returns the list of ignored files and folders . Only the root
* folder of an ignored folder hierarchy is reported . If a / b / c is listed in
* the . gitignore then you should not expect a / b / c / d / e / f to be reported
* here . Only a / b / c will be reported . Furthermore only ignored files /
* folders are returned that are NOT in the index .
*
* @return ignored paths
* /
public Set < String > getIgnoredPaths ( ) {
return ignoredPaths ;
}
}