diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2020-07-14 06:13:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-14 06:13:36 +0200 |
commit | 41758ec4b81c557092d7566c3eed46f89c1ec3cc (patch) | |
tree | 0b7dc168e08faa29c97b49e3941ddc27458e811c /plumbing/format/gitignore/dir.go | |
parent | ef33fff761a2fabb7f0daf0c1779d2dfac1056da (diff) | |
parent | a8a0f9ff848509e6e9050fd86f35c12abbdc12d4 (diff) | |
download | go-git-41758ec4b81c557092d7566c3eed46f89c1ec3cc.tar.gz |
Merge pull request #115 from blaueled/fix/gitignore-crlf
.gitignore crlf fix
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) { |