From be8d19438ada078a8598e366ab74aa09e4c521cd Mon Sep 17 00:00:00 2001 From: Antonio Jesus Navarro Perez Date: Mon, 10 Apr 2017 16:48:40 +0200 Subject: Add Repository.Log() method (fix #298) - CommitIter is now an interface - The old CommitIter implementation is now called StorerCommitIter - CommitWalker and CommitWalkerPost are now iterators (CommitPreIterator and CommitPostIterator). - Remove Commit.History() method. There are so many ways to iterate a commit history, depending of the use case. Now, instead of use the History() method, you must use CommitPreIterator or CommitPostIterator. - Move commitSorterer to references.go because is the only place that it is used, and it must not be used into another place. - Make References method private, it must only be used into blame logic. - Added a TODO into references method, where the sortCommits is used to remove it in a near future. --- plumbing/revlist/revlist.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'plumbing/revlist') diff --git a/plumbing/revlist/revlist.go b/plumbing/revlist/revlist.go index eb9afaf..fbd1bd9 100644 --- a/plumbing/revlist/revlist.go +++ b/plumbing/revlist/revlist.go @@ -82,20 +82,21 @@ func reachableObjects( commit *object.Commit, seen map[plumbing.Hash]bool, cb func(h plumbing.Hash)) error { - return object.WalkCommitHistory(commit, func(commit *object.Commit) error { - if seen[commit.Hash] { - return nil - } + return object.NewCommitPreIterator(commit). + ForEach(func(commit *object.Commit) error { + if seen[commit.Hash] { + return nil + } - cb(commit.Hash) + cb(commit.Hash) - tree, err := commit.Tree() - if err != nil { - return err - } + tree, err := commit.Tree() + if err != nil { + return err + } - return iterateCommitTrees(seen, tree, cb) - }) + return iterateCommitTrees(seen, tree, cb) + }) } // iterateCommitTrees iterate all reachable trees from the given commit -- cgit