First lookup if hash exists, then GetCommit.

Signed-off-by: kuba-- <kuba@sourced.tech>
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 @@
 			// 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]