diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-01-21 13:01:59 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-01-21 13:01:59 +0100 |
commit | abe470a3c1b9fae99161ee5531d18d0e3168fdfa (patch) | |
tree | c1067a2175af73e8fba349128a860dfeb936abff /commit.go | |
parent | 37cc5cf842c3c0fb989bcf7525cc8f826d96b295 (diff) | |
parent | 5ec2de7f1a563bee521332568df591ef63623232 (diff) | |
download | go-git-abe470a3c1b9fae99161ee5531d18d0e3168fdfa.tar.gz |
Merge pull request #14 from alcortesm/fix-file-iterator-gorutine-leak
Fix commit.File() gorutine leak
Diffstat (limited to 'commit.go')
-rw-r--r-- | commit.go | 11 |
1 files changed, 1 insertions, 10 deletions
@@ -3,7 +3,6 @@ package git import ( "bufio" "bytes" - "errors" "fmt" "io" "sort" @@ -11,9 +10,6 @@ import ( "gopkg.in/src-d/go-git.v2/core" ) -// New errors defined by this package. -var ErrFileNotFound = errors.New("file not found") - type Hash core.Hash // Commit points to a single tree, marking it as what the project looked like @@ -59,12 +55,7 @@ func (c *Commit) NumParents() int { // nil error if the file exists. If the file does not exists, it returns // a nil file and the ErrFileNotFound error. func (c *Commit) File(path string) (file *File, err error) { - for file := range c.Tree().Files() { - if file.Name == path { - return file, nil - } - } - return nil, ErrFileNotFound + return c.Tree().File(path) } // Decode transform an core.Object into a Blob struct |