private boolean isModified(String path) throws CorruptObjectException, IOException { NameConflictTreeWalk tw = new NameConflictTreeWalk(repo); tw.addTree(new DirCacheIterator(dc)); tw.addTree(new FileTreeIterator(repo)); tw.setRecursive(true); tw.setFilter(PathFilter.create(path)); DirCacheIterator dcIt; WorkingTreeIterator wtIt; while (tw.next()) { dcIt = tw.getTree(0, DirCacheIterator.class); wtIt = tw.getTree(1, WorkingTreeIterator.class); if (dcIt == null || wtIt == null) return true; if (wtIt.isModified(dcIt.getDirCacheEntry(), true)) { return true; } } return false; }
/** * Scan head, index and merge tree. Used during normal checkout or merge operations. * * @throws CorruptObjectException * @throws IOException */ public void preScanTwoTrees() throws CorruptObjectException, IOException { removed.clear(); updated.clear(); conflicts.clear(); walk = new NameConflictTreeWalk(repo); builder = dc.builder(); addTree(walk, headCommitTree); addTree(walk, mergeCommitTree); walk.addTree(new DirCacheBuildIterator(builder)); walk.addTree(workingTree); while (walk.next()) { processEntry( walk.getTree(0, CanonicalTreeParser.class), walk.getTree(1, CanonicalTreeParser.class), walk.getTree(2, DirCacheBuildIterator.class), walk.getTree(3, WorkingTreeIterator.class)); if (walk.isSubtree()) walk.enterSubtree(); } }
/** * Scan index and merge tree (no HEAD). Used e.g. for initial checkout when there is no head yet. * * @throws MissingObjectException * @throws IncorrectObjectTypeException * @throws CorruptObjectException * @throws IOException */ public void prescanOneTree() throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { removed.clear(); updated.clear(); conflicts.clear(); builder = dc.builder(); walk = new NameConflictTreeWalk(repo); walk.addTree(mergeCommitTree); walk.addTree(new DirCacheBuildIterator(builder)); walk.addTree(workingTree); while (walk.next()) { processEntry( walk.getTree(0, CanonicalTreeParser.class), walk.getTree(1, DirCacheBuildIterator.class), walk.getTree(2, WorkingTreeIterator.class)); if (walk.isSubtree()) walk.enterSubtree(); } conflicts.removeAll(removed); }