diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-09-12 11:20:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-12 11:20:29 +0200 |
commit | 8cb0215282c329d299d7d1d195abae4704981ba6 (patch) | |
tree | c499cf7ac25842c818d31c690bedb602940e13db /plumbing/object/commit_walker.go | |
parent | 032ec287ec496117dc85cd0e9c9224b2b17f5398 (diff) | |
parent | 841b62a321b3739381b48aeea7364126d1c54520 (diff) | |
download | go-git-8cb0215282c329d299d7d1d195abae4704981ba6.tar.gz |
Merge pull request #586 from keybase/strib/commit-preorder-seen-gh-master
plumbing: the commit walker can skip externally-seen commits
Diffstat (limited to 'plumbing/object/commit_walker.go')
-rw-r--r-- | plumbing/object/commit_walker.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/plumbing/object/commit_walker.go b/plumbing/object/commit_walker.go index 797c17a..40ad258 100644 --- a/plumbing/object/commit_walker.go +++ b/plumbing/object/commit_walker.go @@ -8,9 +8,10 @@ import ( ) type commitPreIterator struct { - seen map[plumbing.Hash]bool - stack []CommitIter - start *Commit + seenExternal map[plumbing.Hash]bool + seen map[plumbing.Hash]bool + stack []CommitIter + start *Commit } // NewCommitPreorderIter returns a CommitIter that walks the commit history, @@ -20,16 +21,21 @@ type commitPreIterator struct { // and will return the error. Other errors might be returned if the history // cannot be traversed (e.g. missing objects). Ignore allows to skip some // commits from being iterated. -func NewCommitPreorderIter(c *Commit, ignore []plumbing.Hash) CommitIter { +func NewCommitPreorderIter( + c *Commit, + seenExternal map[plumbing.Hash]bool, + ignore []plumbing.Hash, +) CommitIter { seen := make(map[plumbing.Hash]bool) for _, h := range ignore { seen[h] = true } return &commitPreIterator{ - seen: seen, - stack: make([]CommitIter, 0), - start: c, + seenExternal: seenExternal, + seen: seen, + stack: make([]CommitIter, 0), + start: c, } } @@ -57,7 +63,7 @@ func (w *commitPreIterator) Next() (*Commit, error) { } } - if w.seen[c.Hash] { + if w.seen[c.Hash] || w.seenExternal[c.Hash] { continue } |