fix(ignore): handle pattern resulting in empty string (#10835)

Minor fix to avoid a panic in ignore matching.

Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
Jakob Borg
2026-07-26 20:50:14 +02:00
committed by GitHub
parent 703b185982
commit b8a255cc96
2 changed files with 16 additions and 1 deletions
+5 -1
View File
@@ -92,7 +92,7 @@ func (p Pattern) allowsSkippingIgnoredDirs() bool {
if p.result.IsIgnored() {
return true
}
if p.pattern[0] != '/' {
if p.pattern == "" || p.pattern[0] != '/' {
return false
}
// A "/**" at the end is allowed and doesn't have any bearing on the
@@ -412,6 +412,10 @@ func parseLine(line string) ([]Pattern, error) {
patterns[0] = pattern
line = line[3:]
if line == "" {
// Pattern was exactly "**/", already covered by patterns[0].
return patterns[:1], nil
}
pattern.pattern = line
pattern.match, err = glob.Compile(line, '/')
if err != nil {