aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-08-20 09:45:46 +0200
committerGitHub <noreply@github.com>2018-08-20 09:45:46 +0200
commit1cef577576855d92ca4a3b23e205d08b3dac9027 (patch)
tree50ac00b7d3f271ed6e17a45e69390ed57eab02c8 /plumbing/format
parent7b6c1266556f59ac436fada3fa6106d4a84f9b56 (diff)
parent7b4a8379327653167e87e9e46a2d397f8fd9cfc8 (diff)
downloadgo-git-1cef577576855d92ca4a3b23e205d08b3dac9027.tar.gz
Merge pull request #924 from fkorotkov/fedor/fix-issue-923
Fixed an edge case for .gitignore
Diffstat (limited to 'plumbing/format')
-rw-r--r--plumbing/format/gitignore/pattern.go3
-rw-r--r--plumbing/format/gitignore/pattern_test.go6
2 files changed, 9 insertions, 0 deletions
diff --git a/plumbing/format/gitignore/pattern.go b/plumbing/format/gitignore/pattern.go
index 2603352..098cb50 100644
--- a/plumbing/format/gitignore/pattern.go
+++ b/plumbing/format/gitignore/pattern.go
@@ -133,6 +133,9 @@ func (p *pattern) globMatch(path []string, isDir bool) bool {
} else if match {
matched = true
break
+ } else if len(path) == 0 {
+ // if nothing left then fail
+ matched = false
}
}
} else {
diff --git a/plumbing/format/gitignore/pattern_test.go b/plumbing/format/gitignore/pattern_test.go
index f94cef3..c410442 100644
--- a/plumbing/format/gitignore/pattern_test.go
+++ b/plumbing/format/gitignore/pattern_test.go
@@ -281,3 +281,9 @@ func (s *PatternSuite) TestGlobMatch_wrongPattern_onTraversal_mismatch(c *C) {
r := p.Match([]string{"value", "head", "vol["}, false)
c.Assert(r, Equals, NoMatch)
}
+
+func (s *PatternSuite) TestGlobMatch_issue_923(c *C) {
+ p := ParsePattern("**/android/**/GeneratedPluginRegistrant.java", nil)
+ r := p.Match([]string{"packages", "flutter_tools", "lib", "src", "android", "gradle.dart"}, false)
+ c.Assert(r, Equals, NoMatch)
+}