/** * Pop the next most recent object. * * @return next most recent object; null if traversal is over. * @throws MissingObjectException one or or more of the next objects are not available from the * object database, but were thought to be candidates for traversal. This usually indicates a * broken link. * @throws IncorrectObjectTypeException one or or more of the objects in a tree do not match the * type indicated. * @throws IOException a pack file or loose object could not be read. */ public RevObject nextObject() throws MissingObjectException, IncorrectObjectTypeException, IOException { if (last != null) treeWalk = last instanceof RevTree ? enter(last) : treeWalk.next(); while (!treeWalk.eof()) { final FileMode mode = treeWalk.getEntryFileMode(); switch (mode.getObjectType()) { case Constants.OBJ_BLOB: { treeWalk.getEntryObjectId(idBuffer); final RevBlob o = lookupBlob(idBuffer); if ((o.flags & SEEN) != 0) break; o.flags |= SEEN; if (shouldSkipObject(o)) break; last = o; return o; } case Constants.OBJ_TREE: { treeWalk.getEntryObjectId(idBuffer); final RevTree o = lookupTree(idBuffer); if ((o.flags & SEEN) != 0) break; o.flags |= SEEN; if (shouldSkipObject(o)) break; last = o; return o; } default: if (FileMode.GITLINK.equals(mode)) break; treeWalk.getEntryObjectId(idBuffer); throw new CorruptObjectException( MessageFormat.format( JGitText.get().corruptObjectInvalidMode3, mode, idBuffer.name(), treeWalk.getEntryPathString(), currentTree.name())); } treeWalk = treeWalk.next(); } last = null; for (; ; ) { final RevObject o = pendingObjects.next(); if (o == null) return null; if ((o.flags & SEEN) != 0) continue; o.flags |= SEEN; if (shouldSkipObject(o)) continue; if (o instanceof RevTree) { currentTree = (RevTree) o; treeWalk = treeWalk.resetRoot(db, currentTree, curs); } return o; } }
private void markTreeUninteresting(final RevTree tree) throws MissingObjectException, IncorrectObjectTypeException, IOException { if ((tree.flags & UNINTERESTING) != 0) return; tree.flags |= UNINTERESTING; treeWalk = treeWalk.resetRoot(db, tree, curs); while (!treeWalk.eof()) { final FileMode mode = treeWalk.getEntryFileMode(); final int sType = mode.getObjectType(); switch (sType) { case Constants.OBJ_BLOB: { treeWalk.getEntryObjectId(idBuffer); lookupBlob(idBuffer).flags |= UNINTERESTING; break; } case Constants.OBJ_TREE: { treeWalk.getEntryObjectId(idBuffer); final RevTree t = lookupTree(idBuffer); if ((t.flags & UNINTERESTING) == 0) { t.flags |= UNINTERESTING; treeWalk = treeWalk.createSubtreeIterator0(db, t, curs); continue; } break; } default: if (FileMode.GITLINK.equals(mode)) break; treeWalk.getEntryObjectId(idBuffer); throw new CorruptObjectException( MessageFormat.format( JGitText.get().corruptObjectInvalidMode3, mode, idBuffer.name(), treeWalk.getEntryPathString(), tree)); } treeWalk = treeWalk.next(); } }