private void MarkTreeUninteresting(RevObject tree) { if ((tree.Flags & UNINTERESTING) != 0) { return; } tree.Flags |= UNINTERESTING; _treeWalk = _treeWalk.resetRoot(Repository, tree, WindowCursor); while (!_treeWalk.eof()) { FileMode mode = _treeWalk.EntryFileMode; var sType = (int)mode.ObjectType; switch (sType) { case Constants.OBJ_BLOB: _treeWalk.getEntryObjectId(IdBuffer); lookupBlob(IdBuffer).Flags |= UNINTERESTING; break; case Constants.OBJ_TREE: _treeWalk.getEntryObjectId(IdBuffer); RevTree t = lookupTree(IdBuffer); if ((t.Flags & UNINTERESTING) == 0) { t.Flags |= UNINTERESTING; _treeWalk = _treeWalk.createSubtreeIterator0(Repository, t, WindowCursor); continue; } break; default: if (FileMode.GitLink == FileMode.FromBits(mode.Bits)) { break; } _treeWalk.getEntryObjectId(IdBuffer); throw new CorruptObjectException("Invalid mode " + mode + " for " + IdBuffer + " " + _treeWalk.EntryPathString + " in " + tree + "."); } _treeWalk = _treeWalk.next(); } }
/// <summary> /// Pop the next most recent object. /// </summary> /// <returns>next most recent object; null if traversal is over.</returns> /// <exception cref="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. /// </exception> /// <exception cref="IncorrectObjectTypeException"> /// One or or more of the objects in a tree do not match the type indicated. /// </exception> /// <exception cref="Exception"> /// A pack file or loose object could not be Read. /// </exception> public RevObject nextObject() { _fromTreeWalk = false; if (_nextSubtree != null) { _treeWalk = _treeWalk.createSubtreeIterator0(Repository, _nextSubtree, WindowCursor); _nextSubtree = null; } while (!_treeWalk.eof()) { FileMode mode = _treeWalk.EntryFileMode; var sType = (int)mode.ObjectType; switch (sType) { case Constants.OBJ_BLOB: _treeWalk.getEntryObjectId(IdBuffer); RevBlob blob = lookupBlob(IdBuffer); if ((blob.Flags & SEEN) != 0) { break; } blob.Flags |= SEEN; if (ShouldSkipObject(blob)) { break; } _fromTreeWalk = true; return(blob); case Constants.OBJ_TREE: _treeWalk.getEntryObjectId(IdBuffer); RevTree tree = lookupTree(IdBuffer); if ((tree.Flags & SEEN) != 0) { break; } tree.Flags |= SEEN; if (ShouldSkipObject(tree)) { break; } _nextSubtree = tree; _fromTreeWalk = true; return(tree); default: if (FileMode.GitLink.Equals(mode.Bits)) { break; } _treeWalk.getEntryObjectId(IdBuffer); throw new CorruptObjectException("Invalid mode " + mode + " for " + IdBuffer + " " + _treeWalk.EntryPathString + " in " + _currentTree + "."); } _treeWalk = _treeWalk.next(); } while (true) { RevObject obj = _pendingObjects.next(); if (obj == null) { return(null); } if ((obj.Flags & SEEN) != 0) { continue; } obj.Flags |= SEEN; if (ShouldSkipObject(obj)) { continue; } RevTree oTree = (obj as RevTree); if (oTree != null) { _currentTree = oTree; _treeWalk = _treeWalk.resetRoot(Repository, _currentTree, WindowCursor); } return(obj); } }
public void testBackwards_ConfusingPathName() { const string aVeryConfusingName = "confusing 644 entry 755 and others"; ctp.reset(mktree(Entry(m644, "a", hash_a), Entry(mt, aVeryConfusingName, hash_sometree), Entry(m644, "foo", hash_foo))); ctp.next(3); Assert.IsTrue(ctp.eof()); ctp.back(2); Assert.IsFalse(ctp.eof()); Assert.AreEqual(mt.Bits, ctp.Mode); Assert.AreEqual(aVeryConfusingName, Path()); Assert.AreEqual(hash_sometree, ctp.getEntryObjectId()); ctp.back(1); Assert.IsFalse(ctp.eof()); Assert.AreEqual(m644.Bits, ctp.Mode); Assert.AreEqual("a", Path()); Assert.AreEqual(hash_a, ctp.getEntryObjectId()); }