From f65d7f4c42cccd3a1daaef3ce3c3a5cfe006d3c4 Mon Sep 17 00:00:00 2001 From: kuba-- Date: Tue, 8 Jan 2019 11:30:43 +0100 Subject: First lookup if hash exists, then GetCommit. Signed-off-by: kuba-- --- plumbing/object/commit_walker.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'plumbing/object/commit_walker.go') diff --git a/plumbing/object/commit_walker.go b/plumbing/object/commit_walker.go index ab06cb2..92c6572 100644 --- a/plumbing/object/commit_walker.go +++ b/plumbing/object/commit_walker.go @@ -225,18 +225,18 @@ func NewCommitAllIter(s storage.Storer, fn func(*Commit) CommitIter) (CommitIter // we already have the HEAD return nil } - c, _ := GetCommit(s, r.Hash()) - // if it's not a commit - skip it. - if c == nil { - return nil - } - el, ok := m[c.Hash] + el, ok := m[r.Hash()] if ok { return nil } var refCommits []*Commit + c, _ := GetCommit(s, r.Hash()) + // if it's not a commit - skip it. + if c == nil { + return nil + } cit := fn(c) for c, e := cit.Next(); e == nil; { el, ok = m[c.Hash] -- cgit