diff options
author | Arne Westphal <arne.westphal@siemens.com> | 2020-06-29 21:11:13 +0200 |
---|---|---|
committer | Arne Westphal <arne.westphal@siemens.com> | 2020-06-29 21:11:13 +0200 |
commit | 6ac8c9f15d6854b0b9a8e8b95dc17104f68680ce (patch) | |
tree | 8ae2c4d8344d4b65d60d4d257c69fb79b69381f6 /plumbing/format/gitignore/dir.go | |
parent | 9ac753f4afb36feb1a1c22214c16e853db54aa00 (diff) | |
download | go-git-6ac8c9f15d6854b0b9a8e8b95dc17104f68680ce.tar.gz |
replace ReadAll by bufio.scanner
Diffstat (limited to 'plumbing/format/gitignore/dir.go')
-rw-r--r-- | plumbing/format/gitignore/dir.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/plumbing/format/gitignore/dir.go b/plumbing/format/gitignore/dir.go index f4444bf..4a26325 100644 --- a/plumbing/format/gitignore/dir.go +++ b/plumbing/format/gitignore/dir.go @@ -1,6 +1,7 @@ package gitignore import ( + "bufio" "bytes" "io/ioutil" "os" @@ -15,7 +16,6 @@ import ( const ( commentPrefix = "#" coreSection = "core" - eol = "\n" excludesfile = "excludesfile" gitDir = ".git" gitignoreFile = ".gitignore" @@ -29,11 +29,11 @@ func readIgnoreFile(fs billy.Filesystem, path []string, ignoreFile string) (ps [ if err == nil { defer f.Close() - if data, err := ioutil.ReadAll(f); err == nil { - for _, s := range strings.Split(string(data), eol) { - if !strings.HasPrefix(s, commentPrefix) && len(strings.TrimSpace(s)) > 0 { - ps = append(ps, ParsePattern(s, path)) - } + scanner := bufio.NewScanner(f) + for scanner.Scan() { + s := scanner.Text() + if !strings.HasPrefix(s, commentPrefix) && len(strings.TrimSpace(s)) > 0 { + ps = append(ps, ParsePattern(s, path)) } } } else if !os.IsNotExist(err) { |