List of usage examples for org.eclipse.jgit.treewalk.filter InterIndexDiffFilter InterIndexDiffFilter
InterIndexDiffFilter
From source file:org.eclipse.egit.core.internal.indexdiff.IndexDiffCacheEntry.java
License:Open Source License
/** * Refreshes all resources that changed in the index since the last call to * this method. This is suitable for incremental updates on index changed * events/*from w w w . jav a 2s .co m*/ * * For bare repositories this does nothing. */ private void refreshIndexDelta() { if (repository.isBare()) return; try { DirCache currentIndex = repository.readDirCache(); DirCache oldIndex = lastIndex; lastIndex = currentIndex; if (oldIndex == null) { refresh(); // full refresh in case we have no data to compare. return; } Set<String> paths = new TreeSet<String>(); TreeWalk walk = new TreeWalk(repository); try { walk.addTree(new DirCacheIterator(oldIndex)); walk.addTree(new DirCacheIterator(currentIndex)); walk.setFilter(new InterIndexDiffFilter()); while (walk.next()) { if (walk.isSubtree()) walk.enterSubtree(); else paths.add(walk.getPathString()); } } finally { walk.release(); } if (!paths.isEmpty()) refreshFiles(paths); } catch (IOException ex) { Activator.error( MessageFormat.format(CoreText.IndexDiffCacheEntry_errorCalculatingIndexDelta, repository), ex); scheduleReloadJob("Exception while calculating index delta, doing full reload instead"); //$NON-NLS-1$ } }