Skip to content

Commit 6ac8c9f

Browse files
author
Arne Westphal
committed
replace ReadAll by bufio.scanner
1 parent 9ac753f commit 6ac8c9f

File tree

1 file changed

+6
-6
lines changed
  • plumbing/format/gitignore

1 file changed

+6
-6
lines changed

plumbing/format/gitignore/dir.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package gitignore
22

33
import (
4+
"bufio"
45
"bytes"
56
"io/ioutil"
67
"os"
@@ -15,7 +16,6 @@ import (
1516
const (
1617
commentPrefix = "#"
1718
coreSection = "core"
18-
eol = "\n"
1919
excludesfile = "excludesfile"
2020
gitDir = ".git"
2121
gitignoreFile = ".gitignore"
@@ -29,11 +29,11 @@ func readIgnoreFile(fs billy.Filesystem, path []string, ignoreFile string) (ps [
2929
if err == nil {
3030
defer f.Close()
3131

32-
if data, err := ioutil.ReadAll(f); err == nil {
33-
for _, s := range strings.Split(string(data), eol) {
34-
if !strings.HasPrefix(s, commentPrefix) && len(strings.TrimSpace(s)) > 0 {
35-
ps = append(ps, ParsePattern(s, path))
36-
}
32+
scanner := bufio.NewScanner(f)
33+
for scanner.Scan() {
34+
s := scanner.Text()
35+
if !strings.HasPrefix(s, commentPrefix) && len(strings.TrimSpace(s)) > 0 {
36+
ps = append(ps, ParsePattern(s, path))
3737
}
3838
}
3939
} else if !os.IsNotExist(err) {

0 commit comments

Comments
 (0)