mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:47:50 +00:00
filter: document recursive wildcards
Match/ChildMatch accept a ** pattern which is not noted in the doc string, nor do any of the docs or tests specify whether the match is greedy (i.e., can 'foo/**/bar' match paths with additional intermediate bar directories?). Add a note to the doc string and add test cases for greedy matches.
This commit is contained in:
@@ -17,6 +17,10 @@ var ErrBadString = errors.New("filter.Match: string is empty")
|
||||
//
|
||||
// Pattern can be a combination of patterns suitable for filepath.Match, joined
|
||||
// by filepath.Separator.
|
||||
//
|
||||
// In addition patterns suitable for filepath.Match, pattern accepts a
|
||||
// recursive wildcard '**', which greedily matches an arbitrary number of
|
||||
// intermediate directories.
|
||||
func Match(pattern, str string) (matched bool, err error) {
|
||||
if pattern == "" {
|
||||
return true, nil
|
||||
@@ -46,6 +50,10 @@ func Match(pattern, str string) (matched bool, err error) {
|
||||
//
|
||||
// Pattern can be a combination of patterns suitable for filepath.Match, joined
|
||||
// by filepath.Separator.
|
||||
//
|
||||
// In addition patterns suitable for filepath.Match, pattern accepts a
|
||||
// recursive wildcard '**', which greedily matches an arbitrary number of
|
||||
// intermediate directories.
|
||||
func ChildMatch(pattern, str string) (matched bool, err error) {
|
||||
if pattern == "" {
|
||||
return true, nil
|
||||
|
||||
Reference in New Issue
Block a user