From dd65ac56efd168d19be577b241621ab6d5a8ebc2 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 16 Apr 2017 20:49:20 +0200 Subject: [PATCH] filter: Ignore empty patterns --- src/restic/filter/filter.go | 7 ++++++- src/restic/filter/filter_test.go | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/restic/filter/filter.go b/src/restic/filter/filter.go index bb483d31c..37b58f7ef 100644 --- a/src/restic/filter/filter.go +++ b/src/restic/filter/filter.go @@ -100,9 +100,14 @@ func match(patterns, strs []string) (matched bool, err error) { return false, nil } -// List returns true if str matches one of the patterns. +// List returns true if str matches one of the patterns. Empty patterns are +// ignored. func List(patterns []string, str string) (matched bool, err error) { for _, pat := range patterns { + if pat == "" { + continue + } + matched, err = Match(pat, str) if err != nil { return false, err diff --git a/src/restic/filter/filter_test.go b/src/restic/filter/filter_test.go index 2fb04cdf5..232e2c4d3 100644 --- a/src/restic/filter/filter_test.go +++ b/src/restic/filter/filter_test.go @@ -152,6 +152,7 @@ var filterListTests = []struct { {[]string{"?", "x"}, "/foo/bar/x", true}, {[]string{"/*/*/bar/test.*"}, "/foo/bar/test.go", false}, {[]string{"/*/*/bar/test.*", "*.go"}, "/foo/bar/test.go", true}, + {[]string{"", "*.c"}, "/foo/bar/test.go", false}, } func TestMatchList(t *testing.T) {