GitSharp.Core.RevWalk.ObjectWalk.nextObject C# (CSharp) Method

nextObject() public method

Pop the next most recent object.
/// 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. /// /// One or or more of the objects in a tree do not match the type indicated. /// /// A pack file or loose object could not be Read. ///
public nextObject ( ) : RevObject
return RevObject
        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;
            }
        }