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:
commit
2a915069a8
3 changed files with 13 additions and 0 deletions
7
changelog/unreleased/issue-3380
Normal file
7
changelog/unreleased/issue-3380
Normal 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
|
|
@ -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)
|
||||
|
|
|
@ -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},
|
||||
|
|
Loading…
Reference in a new issue