Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit def6979

Browse files
committed
Fixed an edge case for .gitignore
Fixes #923
1 parent 7b6c126 commit def6979

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

plumbing/format/gitignore/pattern.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ func (p *pattern) globMatch(path []string, isDir bool) bool {
133133
} else if match {
134134
matched = true
135135
break
136+
} else if len(path) == 0 {
137+
// if nothing left then fail
138+
matched = false
136139
}
137140
}
138141
} else {

plumbing/format/gitignore/pattern_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,9 @@ func (s *PatternSuite) TestGlobMatch_wrongPattern_onTraversal_mismatch(c *C) {
281281
r := p.Match([]string{"value", "head", "vol["}, false)
282282
c.Assert(r, Equals, NoMatch)
283283
}
284+
285+
func (s *PatternSuite) TestGlobMatch_issue_923(c *C) {
286+
p := ParsePattern("**/android/**/GeneratedPluginRegistrant.java", nil)
287+
r := p.Match([]string{"packages", "flutter_tools", "lib", "src", "android", "gradle.dart"}, false)
288+
c.Assert(r, Equals, NoMatch)
289+
}

0 commit comments

Comments
 (0)