lib/ignore: Fix caching of filenames with path separators on windows (#9600)

Previously we queried cache with backslashes, and stored entries with
slashes. As in no cache hits ever for non-toplevel files. I also
eventually remembered that cache is disabled by default, so this is a
bit pointless, but still right :P
This commit is contained in:
Simon Frei 2024-07-02 12:58:06 +02:00 committed by GitHub
parent 4704d3bc48
commit 403ce7e597
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -231,6 +231,8 @@ func (m *Matcher) Match(file string) (result ignoreresult.R) {
return ignoreresult.NotIgnored return ignoreresult.NotIgnored
} }
file = filepath.ToSlash(file)
if m.matches != nil { if m.matches != nil {
// Check the cache for a known result. // Check the cache for a known result.
res, ok := m.matches.get(file) res, ok := m.matches.get(file)
@ -248,7 +250,6 @@ func (m *Matcher) Match(file string) (result ignoreresult.R) {
// allow skipping matched directories or not. As soon as we hit an // allow skipping matched directories or not. As soon as we hit an
// exclude pattern (with some exceptions), we can't skip directories // exclude pattern (with some exceptions), we can't skip directories
// anymore. // anymore.
file = filepath.ToSlash(file)
var lowercaseFile string var lowercaseFile string
canSkipDir := true canSkipDir := true
for _, pattern := range m.patterns { for _, pattern := range m.patterns {