private void resetUntracked(RevTree tree) throws CheckoutConflictException, IOException {
TreeWalk walk = null;
try {
walk = new TreeWalk(repo); // maybe NameConflictTreeWalk?
walk.addTree(tree);
walk.addTree(new FileTreeIterator(repo));
walk.setRecursive(true);
final ObjectReader reader = walk.getObjectReader();
while (walk.next()) {
final AbstractTreeIterator cIter = walk.getTree(0, AbstractTreeIterator.class);
if (cIter == null)
// Not in commit, don't create untracked
continue;
final DirCacheEntry entry = new DirCacheEntry(walk.getRawPath());
entry.setFileMode(cIter.getEntryFileMode());
entry.setObjectIdFromRaw(cIter.idBuffer(), cIter.idOffset());
FileTreeIterator fIter = walk.getTree(1, FileTreeIterator.class);
if (fIter != null) {
if (fIter.isModified(entry, true, reader)) {
// file exists and is dirty
throw new CheckoutConflictException(entry.getPathString());
}
}