diff options
Diffstat (limited to 'plumbing/object/file.go')
-rw-r--r-- | plumbing/object/file.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/plumbing/object/file.go b/plumbing/object/file.go index 618cea7..4caed6b 100644 --- a/plumbing/object/file.go +++ b/plumbing/object/file.go @@ -56,15 +56,20 @@ func (f *File) Lines() ([]string, error) { return splits, nil } +// FileIter provides an iterator for the files in a tree. type FileIter struct { s storer.EncodedObjectStorer w TreeWalker } +// NewFileIter takes a storer.EncodedObjectStorer and a Tree and returns a +// *FileIter that iterates over all files contained in the tree, recursively. func NewFileIter(s storer.EncodedObjectStorer, t *Tree) *FileIter { return &FileIter{s: s, w: *NewTreeWalker(t, true)} } +// Next moves the iterator to the next file and returns a pointer to it. If +// there are no more files, it returns io.EOF. func (iter *FileIter) Next() (*File, error) { for { name, entry, err := iter.w.Next() |