|
|
@ -50,32 +50,26 @@ import org.eclipse.jgit.treewalk.TreeWalk; |
|
|
|
import org.eclipse.jgit.treewalk.WorkingTreeIterator; |
|
|
|
import org.eclipse.jgit.treewalk.WorkingTreeIterator; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* This filter includes workdir entries that are not ignored. This class is |
|
|
|
* Skip {@link WorkingTreeIterator} entries that appear in gitignore files. |
|
|
|
* immutable. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class NotIgnoredFilter extends TreeFilter { |
|
|
|
public class NotIgnoredFilter extends TreeFilter { |
|
|
|
|
|
|
|
private final int index; |
|
|
|
private final int workdirTreeIndex; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* constructor |
|
|
|
* Construct a filter to ignore paths known to a particular iterator. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param workdirTreeIndex |
|
|
|
* @param workdirTreeIndex |
|
|
|
* index of the workdir tree in the tree walk |
|
|
|
* index of the workdir tree in the tree walk |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public NotIgnoredFilter(final int workdirTreeIndex) { |
|
|
|
public NotIgnoredFilter(final int workdirTreeIndex) { |
|
|
|
this.workdirTreeIndex = workdirTreeIndex; |
|
|
|
this.index = workdirTreeIndex; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean include(TreeWalk walker) throws MissingObjectException, |
|
|
|
public boolean include(TreeWalk tw) throws MissingObjectException, |
|
|
|
IncorrectObjectTypeException, IOException { |
|
|
|
IncorrectObjectTypeException, IOException { |
|
|
|
WorkingTreeIterator workingTreeIterator = walker.getTree( |
|
|
|
WorkingTreeIterator i = tw.getTree(index, WorkingTreeIterator.class); |
|
|
|
workdirTreeIndex, WorkingTreeIterator.class); |
|
|
|
return i == null || !i.isEntryIgnored(); |
|
|
|
if (workingTreeIterator != null) |
|
|
|
|
|
|
|
// do not include ignored entries
|
|
|
|
|
|
|
|
return !workingTreeIterator.isEntryIgnored(); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -89,4 +83,8 @@ public class NotIgnoredFilter extends TreeFilter { |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String toString() { |
|
|
|
|
|
|
|
return "NotIgnored(" + index + ")"; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|