aboutsummaryrefslogtreecommitdiffstats
path: root/commit.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-22 03:29:05 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-22 03:29:05 +0200
commit2ed3474ab8e52c98a87e390d5128d45d693a115d (patch)
tree6f136c2508c22f6b5146ef08c49821a45a5f2357 /commit.go
parent5b13c1a2e55cb442484d9c7b45389f422b110eec (diff)
downloadgo-git-2ed3474ab8e52c98a87e390d5128d45d693a115d.tar.gz
ForEach review and Commit.Tree err return
Diffstat (limited to 'commit.go')
-rw-r--r--commit.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/commit.go b/commit.go
index 5c9c113..4a4a202 100644
--- a/commit.go
+++ b/commit.go
@@ -30,9 +30,8 @@ type Commit struct {
}
// Tree returns the Tree from the commit
-func (c *Commit) Tree() *Tree {
- tree, _ := c.r.Tree(c.tree) // FIXME: Return error as well?
- return tree
+func (c *Commit) Tree() (*Tree, error) {
+ return c.r.Tree(c.tree)
}
// Parents return a CommitIter to the parent Commits
@@ -51,8 +50,13 @@ func (c *Commit) NumParents() int {
// File returns the file with the specified "path" in the commit and a
// nil error if the file exists. If the file does not exist, it returns
// a nil file and the ErrFileNotFound error.
-func (c *Commit) File(path string) (file *File, err error) {
- return c.Tree().File(path)
+func (c *Commit) File(path string) (*File, error) {
+ tree, err := c.Tree()
+ if err != nil {
+ return nil, err
+ }
+
+ return tree.File(path)
}
// ID returns the object ID of the commit. The returned value will always match
@@ -156,7 +160,7 @@ func (iter *CommitIter) Next() (*Commit, error) {
// ForEach call the cb function for each commit contained on this iter until
// an error happends or the end of the iter is reached. If ErrStop is sent
-// the iteration is stop but no error is returned
+// the iteration is stop but no error is returned. The iterator is closed.
func (iter *CommitIter) ForEach(cb func(*Commit) error) error {
return iter.ObjectIter.ForEach(func(obj core.Object) error {
commit := &Commit{r: iter.r}