org.eclipse.jgit.dircache.DirCache as part of a
TreeWalk.
Like org. this iterator allows
a DirCache to be used in parallel with other sorts of iterators in a
TreeWalk. However any entry which appears in the source DirCache and which is
skipped by the TreeFilter is automatically copied into
org., thus retaining it in the
newly updated index.
This iterator is suitable for update processes, or even a simple delete algorithm. For example deleting a path:
final DirCache dirc = db.lockDirCache();
final DirCacheBuilder edit = dirc.builder();
final TreeWalk walk = new TreeWalk(db);
walk.reset();
walk.setRecursive(true);
walk.setFilter(PathFilter.create("name/to/remove"));
walk.addTree(new DirCacheBuildIterator(edit));
while (walk.next())
; // do nothing on a match as we want to remove matches
edit.commit();
| Modifier and Type | Field and Description |
|---|---|
| private final DirCacheBuilder |
| Access | Constructor and Description |
|---|---|
| public | DirCacheBuildIterator(DirCacheBuilder
the cache builder for the cache to walk. The cache must be
already loaded into memory. dcb)Create a new iterator for an already loaded DirCache instance. |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public AbstractTreeIterator | createSubtreeIterator(ObjectReader
reader to load the tree data from. reader)Overrides org. Create a new iterator for the current entry's subtree. |
| protected boolean | needsStopWalk()
Overrides org. Whether the iterator implements |
| public void | skip()
Overrides org. Advance to the next tree entry, populating this iterator with its data. |
| public void | stopWalk()
Overrides org. Indicates to the iterator that no more entries will be read. |
| builder | back to summary |
|---|---|
| private final DirCacheBuilder builder | |
| DirCacheBuildIterator | back to summary |
|---|---|
| public DirCacheBuildIterator(DirCacheBuilder dcb) Create a new iterator for an already loaded DirCache instance. The iterator implementation may copy part of the cache's data during construction, so the cache must be read in prior to creating the iterator.
| |
| DirCacheBuildIterator | back to summary |
|---|---|
| pack-priv DirCacheBuildIterator(final DirCacheBuildIterator p, final DirCacheTree dct) | |
| createSubtreeIterator | back to summary |
|---|---|
| public AbstractTreeIterator createSubtreeIterator(ObjectReader reader) throws IncorrectObjectTypeException, IOException Overrides org. Doc from org. Create a new iterator for the current entry's subtree.
The parent reference of the iterator must be
| |
| needsStopWalk | back to summary |
|---|---|
| protected boolean needsStopWalk() Overrides org. Doc from org. Whether the iterator implements
| |
| skip | back to summary |
|---|---|
| public void skip() throws CorruptObjectException Overrides org. Doc from org. Advance to the next tree entry, populating this iterator with its data.
This method behaves like
| |
| stopWalk | back to summary |
|---|---|
| public void stopWalk() Overrides org. Doc from org. Indicates to the iterator that no more entries will be read.
This is only invoked by TreeWalk when the iteration is aborted early due
to a
| |