DirCacheBuilder builder = dc.builder();
final TreeWalk tw = new TreeWalk(repo);
tw.reset(); // drop the first empty tree, which we do not need here
tw.setRecursive(true);
tw.setFilter(PathFilterGroup.createFromStrings(filepatterns));
tw.addTree(new DirCacheBuildIterator(builder));
while (tw.next()) {
final File path = new File(repo.getWorkTree(),
tw.getPathString());
final FileMode mode = tw.getFileMode(0);