diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2015-11-17 09:19:51 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2015-11-17 09:19:51 +0100 |
commit | eb57cb07025845868e40e3994ba2ec818fd3b4f7 (patch) | |
tree | abab30e22f524efa913d0f60ffa40d3bd5fdd596 /commit.go | |
parent | 491de646e625801d2f809ed4a99c7ace019a3f15 (diff) | |
download | go-git-eb57cb07025845868e40e3994ba2ec818fd3b4f7.tar.gz |
iters: add IsClosed field, fixes #4
Diffstat (limited to 'commit.go')
-rw-r--r-- | commit.go | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -113,17 +113,28 @@ func (i *CommitIter) Next() (*Commit, error) { type iter struct { ch chan core.Object r *Repository + + IsClosed bool } func newIter(r *Repository) iter { ch := make(chan core.Object, 1) - return iter{ch, r} + return iter{ch: ch, r: r} } func (i *iter) Add(o core.Object) { + if i.IsClosed { + return + } + i.ch <- o } func (i *iter) Close() { + if i.IsClosed { + return + } + + defer func() { i.IsClosed = true }() close(i.ch) } |