aboutsummaryrefslogtreecommitdiffstats
path: root/tree_walker.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-03-08 23:30:52 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-03-08 23:30:52 +0100
commitb35fc295b4ac531adc72fc83f2af628c7c163c0e (patch)
tree0282f20de8279db354233d1d67e3743e08509020 /tree_walker.go
parent9c9cdff966cc181296f400769d3c8596f17e743a (diff)
parent9e6a03b7956464ccd9d2fbacedd8e5cc23572d02 (diff)
downloadgo-git-b35fc295b4ac531adc72fc83f2af628c7c163c0e.tar.gz
Merge pull request #39 from scjalliance/git-object-interface
Added Object interface for Commit, Tree, Blob and Tag
Diffstat (limited to 'tree_walker.go')
-rw-r--r--tree_walker.go16
1 files changed, 5 insertions, 11 deletions
diff --git a/tree_walker.go b/tree_walker.go
index 3272718..ff44e67 100644
--- a/tree_walker.go
+++ b/tree_walker.go
@@ -3,8 +3,6 @@ package git
import (
"io"
"path"
-
- "gopkg.in/src-d/go-git.v3/core"
)
const (
@@ -40,7 +38,7 @@ func NewTreeWalker(r *Repository, t *Tree) *TreeWalker {
// In the current implementation any objects which cannot be found in the
// underlying repository will be skipped automatically. It is possible that this
// may change in future versions.
-func (w *TreeWalker) Next() (name string, entry TreeEntry, obj core.Object, err error) {
+func (w *TreeWalker) Next() (name string, entry TreeEntry, obj Object, err error) {
for {
current := len(w.stack) - 1
if current < 0 {
@@ -66,10 +64,11 @@ func (w *TreeWalker) Next() (name string, entry TreeEntry, obj core.Object, err
return
}
- obj, err = w.r.Storage.Get(entry.Hash)
- if err == core.ObjectNotFoundErr {
+ obj, err = w.r.Object(entry.Hash)
+ if err == ObjectNotFoundErr {
// FIXME: Avoid doing this here in case the caller actually cares about
// missing objects.
+ err = nil
continue // ignore entries without hash (= submodule dirs)
}
@@ -82,12 +81,7 @@ func (w *TreeWalker) Next() (name string, entry TreeEntry, obj core.Object, err
break
}
- if obj.Type() == core.TreeObject {
- tree := &Tree{r: w.r}
- err = tree.Decode(obj)
- if err != nil {
- return
- }
+ if tree, ok := obj.(*Tree); ok {
w.stack = append(w.stack, *NewTreeEntryIter(tree))
w.base = path.Join(w.base, entry.Name)
}