aboutsummaryrefslogtreecommitdiffstats
path: root/commit.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-01-21 13:01:59 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-01-21 13:01:59 +0100
commitabe470a3c1b9fae99161ee5531d18d0e3168fdfa (patch)
treec1067a2175af73e8fba349128a860dfeb936abff /commit.go
parent37cc5cf842c3c0fb989bcf7525cc8f826d96b295 (diff)
parent5ec2de7f1a563bee521332568df591ef63623232 (diff)
downloadgo-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.go11
1 files changed, 1 insertions, 10 deletions
diff --git a/commit.go b/commit.go
index 1dd09ab..ea6419f 100644
--- a/commit.go
+++ b/commit.go
@@ -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