diff options
-rw-r--r-- | internal/go-git-gitignore/pattern.go | 7 | ||||
-rw-r--r-- | internal/go-git-gitignore/pattern_test.go | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/internal/go-git-gitignore/pattern.go b/internal/go-git-gitignore/pattern.go index c80e841..94d585f 100644 --- a/internal/go-git-gitignore/pattern.go +++ b/internal/go-git-gitignore/pattern.go @@ -90,6 +90,13 @@ func (p *pattern) Match(path []string, isDir bool) MatchResult { } func (p *pattern) simpleNameMatch(path []string, isDir bool) bool { + // gocryptfs patch: simple fix for https://github.com/go-git/go-git/issues/1596 + // gocryptfs can get away with this because each parent directory has already been checked + // separately on LOOKUP. + if p.dirOnly && !isDir { + return false + } + for i, name := range path { if match, err := filepath.Match(p.pattern[0], name); err != nil { return false diff --git a/internal/go-git-gitignore/pattern_test.go b/internal/go-git-gitignore/pattern_test.go index 17aa16a..a6f4eb1 100644 --- a/internal/go-git-gitignore/pattern_test.go +++ b/internal/go-git-gitignore/pattern_test.go @@ -41,7 +41,7 @@ func (s *PatternSuite) TestMatch_domainMismatch_mismatch() { func (s *PatternSuite) TestSimpleMatch_withDomain() { p := ParsePattern("middle/", []string{"value", "volcano"}) r := p.Match([]string{"value", "volcano", "middle", "tail"}, false) - s.Equal(Exclude, r) + s.Equal(NoMatch, r) } func (s *PatternSuite) TestSimpleMatch_onlyMatchInDomain_mismatch() { @@ -71,13 +71,13 @@ func (s *PatternSuite) TestSimpleMatch_atEnd() { func (s *PatternSuite) TestSimpleMatch_atStart_dirWanted() { p := ParsePattern("value/", nil) r := p.Match([]string{"value", "tail"}, false) - s.Equal(Exclude, r) + s.Equal(NoMatch, r) } func (s *PatternSuite) TestSimpleMatch_inTheMiddle_dirWanted() { p := ParsePattern("value/", nil) r := p.Match([]string{"head", "value", "tail"}, false) - s.Equal(Exclude, r) + s.Equal(NoMatch, r) } func (s *PatternSuite) TestSimpleMatch_atEnd_dirWanted() { |