1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-30 19:57:19 +00:00

Merge pull request #3393 from MichaelEischer/fix-filter-crash

filter: Fix crash for '**' pattern
This commit is contained in:
rawtaz 2021-05-14 23:58:44 +02:00 committed by GitHub
commit 2a915069a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View file

@ -0,0 +1,7 @@
Bugfix: Fix crash of `backup --exclude='**'`
The exclude filter '**', which excludes all files, caused restic to crash. This
has been fixed.
https://github.com/restic/restic/issues/3380
https://github.com/restic/restic/pull/3393

View file

@ -166,6 +166,11 @@ func match(patterns Pattern, strs []string) (matched bool, err error) {
return true, nil
}
// an empty pattern never matches a non-empty path
if len(patterns) == 0 {
return false, nil
}
if len(patterns) <= len(strs) {
minOffset := 0
maxOffset := len(strs) - len(patterns)

View file

@ -23,6 +23,7 @@ var matchTests = []struct {
{"*.go", "/foo/bar/test.go", true},
{"*.c", "/foo/bar/test.go", false},
{"*", "/foo/bar/test.go", true},
{"**", "/foo/bar/test.go", true},
{"foo*", "/foo/bar/test.go", true},
{"bar*", "/foo/bar/test.go", true},
{"/bar*", "/foo/bar/test.go", false},