mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-16 02:18:44 -07:00
lib/ignore: Remove pattern for foo/** which is already covered by foo/
Actual speed difference according to benchmarks is hidden in the noise Also make the "pattern" field for each entry match what is actually evaluated.
This commit is contained in:
parent
cc1d122352
commit
1934b3a5b6
@ -249,7 +249,9 @@ func parseIgnoreFile(fd io.Reader, currentFile string, seen map[string]bool) ([]
|
||||
}
|
||||
patterns = append(patterns, pattern)
|
||||
|
||||
pattern.match, err = glob.Compile(line[3:])
|
||||
line = line[3:]
|
||||
pattern.pattern = line
|
||||
pattern.match, err = glob.Compile(line)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid pattern %q in ignore file", line)
|
||||
}
|
||||
@ -271,7 +273,9 @@ func parseIgnoreFile(fd io.Reader, currentFile string, seen map[string]bool) ([]
|
||||
}
|
||||
patterns = append(patterns, pattern)
|
||||
|
||||
pattern.match, err = glob.Compile("**/" + line)
|
||||
line := "**/" + line
|
||||
pattern.pattern = line
|
||||
pattern.match, err = glob.Compile(line)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid pattern %q in ignore file", line)
|
||||
}
|
||||
@ -299,9 +303,6 @@ func parseIgnoreFile(fd io.Reader, currentFile string, seen map[string]bool) ([]
|
||||
err = addPattern(line)
|
||||
case strings.HasSuffix(line, "/"):
|
||||
err = addPattern(line)
|
||||
if err == nil {
|
||||
err = addPattern(line + "**")
|
||||
}
|
||||
default:
|
||||
err = addPattern(line)
|
||||
if err == nil {
|
||||
|
@ -177,10 +177,6 @@ func TestCaching(t *testing.T) {
|
||||
t.Fatal("Expected empty cache")
|
||||
}
|
||||
|
||||
if len(pats.patterns) != 4 {
|
||||
t.Fatal("Incorrect number of patterns loaded", len(pats.patterns), "!=", 4)
|
||||
}
|
||||
|
||||
// Cache some outcomes
|
||||
|
||||
for _, letter := range []string{"a", "b", "x", "y"} {
|
||||
|
Loading…
Reference in New Issue
Block a user