aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/object/commit_walker.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2019-02-13 17:44:51 +0100
committerGitHub <noreply@github.com>2019-02-13 17:44:51 +0100
commit4d8bd13a73d6efd41b6be0b2eba5130c498fae0d (patch)
treec66ae7ca3b29f8b9d5be869d0de4f0f98591c2d6 /plumbing/object/commit_walker.go
parent2ab6d5cd72b59cfd36b08078ddeebd1efb0d2254 (diff)
parent2b248220113c6eb8699da4aebdb6665b9751f471 (diff)
downloadgo-git-4d8bd13a73d6efd41b6be0b2eba5130c498fae0d.tar.gz
Merge pull request #1067 from ajnavarro/fix/log-all-missing-objects
Ignore missing references/objects on log --all
Diffstat (limited to 'plumbing/object/commit_walker.go')
-rw-r--r--plumbing/object/commit_walker.go34
1 files changed, 23 insertions, 11 deletions
diff --git a/plumbing/object/commit_walker.go b/plumbing/object/commit_walker.go
index 8c76557..0eff059 100644
--- a/plumbing/object/commit_walker.go
+++ b/plumbing/object/commit_walker.go
@@ -197,26 +197,38 @@ func NewCommitAllIter(repoStorer storage.Storer, commitIterFunc func(*Commit) Co
commitsPath := list.New()
commitsLookup := make(map[plumbing.Hash]*list.Element)
head, err := storer.ResolveReference(repoStorer, plumbing.HEAD)
- if err != nil {
- return nil, err
+ if err == nil {
+ err = addReference(repoStorer, commitIterFunc, head, commitsPath, commitsLookup)
}
- // add all references along with the HEAD
- if err = addReference(repoStorer, commitIterFunc, head, commitsPath, commitsLookup); err != nil {
+ if err != nil && err != plumbing.ErrReferenceNotFound {
return nil, err
}
+
+ // add all references along with the HEAD
refIter, err := repoStorer.IterReferences()
if err != nil {
return nil, err
}
defer refIter.Close()
- err = refIter.ForEach(
- func(ref *plumbing.Reference) error {
- return addReference(repoStorer, commitIterFunc, ref, commitsPath, commitsLookup)
- },
- )
- if err != nil {
- return nil, err
+
+ for {
+ ref, err := refIter.Next()
+ if err == io.EOF {
+ break
+ }
+
+ if err == plumbing.ErrReferenceNotFound {
+ continue
+ }
+
+ if err != nil {
+ return nil, err
+ }
+
+ if err = addReference(repoStorer, commitIterFunc, ref, commitsPath, commitsLookup); err != nil {
+ return nil, err
+ }
}
return &commitAllIterator{commitsPath.Front()}, nil