From b40035222a691f1a5840a0fc21c6394e96845a57 Mon Sep 17 00:00:00 2001 From: Winfried Plappert Date: Mon, 23 Dec 2024 07:23:12 +0000 Subject: [PATCH] rewrite command: add include.Empty(), changelog/issue-4278 Prepare filter inclusion filters: add func Empty() Enhancement to enable inclusion filters for rewrite command. --- changelog/unreleased/issue-4278 | 13 +++++++++++++ internal/filter/include.go | 4 ++++ 2 files changed, 17 insertions(+) create mode 100644 changelog/unreleased/issue-4278 diff --git a/changelog/unreleased/issue-4278 b/changelog/unreleased/issue-4278 new file mode 100644 index 000000000..d85d34df7 --- /dev/null +++ b/changelog/unreleased/issue-4278 @@ -0,0 +1,13 @@ +Enhancement: include filters in command rewrite + +The enhancement allows the standard include filter options + --iinclude pattern same as --include pattern but ignores the casing of filenames + --iinclude-file file same as --include-file but ignores casing of filenames in patterns + -i, --include pattern include a pattern (can be specified multiple times) + --include-file file read include patterns from a file (can be specified multiple times) + +The exclusion or inclusion of filter parameters is exclusive, as in other commands +which use both include and exclude filters. + +https://github.com/restic/restic/issues/4278 +https://github.com/restic/restic/pull/5191 diff --git a/internal/filter/include.go b/internal/filter/include.go index 87d5f1207..e6eefe6b9 100644 --- a/internal/filter/include.go +++ b/internal/filter/include.go @@ -25,6 +25,10 @@ func (opts *IncludePatternOptions) Add(f *pflag.FlagSet) { f.StringArrayVar(&opts.InsensitiveIncludeFiles, "iinclude-file", nil, "same as --include-file but ignores casing of `file`names in patterns") } +func (opts *IncludePatternOptions) Empty() bool { + return len(opts.Includes) == 0 && len(opts.InsensitiveIncludes) == 0 && len(opts.IncludeFiles) == 0 && len(opts.InsensitiveIncludeFiles) == 0 +} + func (opts IncludePatternOptions) CollectPatterns(warnf func(msg string, args ...interface{})) ([]IncludeByNameFunc, error) { var fs []IncludeByNameFunc if len(opts.IncludeFiles) > 0 {