diff options
author | Santiago M. Mola <santi@mola.io> | 2016-08-29 22:47:13 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-29 22:47:13 +0200 |
commit | e4246138cb9ffb819c052ba17a9fbdf915427291 (patch) | |
tree | bd938368afe0ffd7c9e1df16256e39e17d8184b5 /tree_walker.go | |
parent | dd4af03ad368cc50dd08912010f5b667bd7569cd (diff) | |
download | go-git-e4246138cb9ffb819c052ba17a9fbdf915427291.tar.gz |
storage: Add object type hint parameter to ObjectStorage.Get. (#69)
Some storage backends can optimize object lookup if they get
the object type that is expected. So we the signature of the Get
method is now Get(Hash, ObjectType).
Added generic tests for storage backends.
Diffstat (limited to 'tree_walker.go')
-rw-r--r-- | tree_walker.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tree_walker.go b/tree_walker.go index 5568e1b..d4aa01a 100644 --- a/tree_walker.go +++ b/tree_walker.go @@ -9,6 +9,9 @@ const ( startingStackSize = 8 ) +const submoduleMode = 0160000 +const directoryMode = 0040000 + // TreeWalker provides a means of walking through all of the entries in a Tree. type TreeWalker struct { stack []treeEntryIter @@ -66,12 +69,14 @@ func (w *TreeWalker) Next() (name string, entry TreeEntry, obj Object, err error return } - obj, err = w.r.Object(entry.Hash) - if err == ErrObjectNotFound { - // FIXME: Avoid doing this here in case the caller actually cares about - // missing objects. + if entry.Mode == submoduleMode { err = nil - continue // ignore entries without hash (= submodule dirs) + continue + } + if entry.Mode.IsDir() { + obj, err = w.r.Tree(entry.Hash) + } else { + obj, err = w.r.Blob(entry.Hash) } name = path.Join(w.base, entry.Name) |