From d7c00b034ff5ce038c168ab16a943cc5f55aac3c Mon Sep 17 00:00:00 2001 From: knqyf263 Date: Sat, 3 Aug 2019 16:02:48 -1000 Subject: Handle io.EOF error in commitFileIter.ForEach Signed-off-by: knqyf263 --- plumbing/object/commit_walker_file.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'plumbing/object') diff --git a/plumbing/object/commit_walker_file.go b/plumbing/object/commit_walker_file.go index 6f16e61..76c158b 100644 --- a/plumbing/object/commit_walker_file.go +++ b/plumbing/object/commit_walker_file.go @@ -128,7 +128,9 @@ func isParentHash(hash plumbing.Hash, commit *Commit) bool { func (c *commitFileIter) ForEach(cb func(*Commit) error) error { for { commit, nextErr := c.Next() - if nextErr != nil { + if nextErr == io.EOF { + break + } else if nextErr != nil { return nextErr } err := cb(commit) @@ -138,6 +140,7 @@ func (c *commitFileIter) ForEach(cb func(*Commit) error) error { return err } } + return nil } func (c *commitFileIter) Close() { -- cgit From a2af865f9dbf292a9804c67abc2727551f7954dd Mon Sep 17 00:00:00 2001 From: knqyf263 Date: Sun, 4 Aug 2019 01:00:33 -1000 Subject: Remove else Signed-off-by: knqyf263 --- plumbing/object/commit_walker_file.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plumbing/object') diff --git a/plumbing/object/commit_walker_file.go b/plumbing/object/commit_walker_file.go index 76c158b..b73e4ce 100644 --- a/plumbing/object/commit_walker_file.go +++ b/plumbing/object/commit_walker_file.go @@ -130,7 +130,8 @@ func (c *commitFileIter) ForEach(cb func(*Commit) error) error { commit, nextErr := c.Next() if nextErr == io.EOF { break - } else if nextErr != nil { + } + if nextErr != nil { return nextErr } err := cb(commit) -- cgit