diff --git a/cmd/restic/cmd_rewrite.go b/cmd/restic/cmd_rewrite.go index fc6284ce8..abab5dfcd 100644 --- a/cmd/restic/cmd_rewrite.go +++ b/cmd/restic/cmd_rewrite.go @@ -152,7 +152,7 @@ func rewriteSnapshot(ctx context.Context, repo *repository.Repository, sn *resti } func runRewrite(ctx context.Context, opts RewriteOptions, gopts GlobalOptions, args []string) error { - if len(opts.ExcludeFiles) == 0 && len(opts.Excludes) == 0 && len(opts.InsensitiveExcludes) == 0 { + if opts.excludePatternOptions.Empty() { return errors.Fatal("Nothing to do: no excludes provided") } diff --git a/cmd/restic/exclude.go b/cmd/restic/exclude.go index 86f85f133..4a1954b88 100644 --- a/cmd/restic/exclude.go +++ b/cmd/restic/exclude.go @@ -475,6 +475,10 @@ func initExcludePatternOptions(f *pflag.FlagSet, opts *excludePatternOptions) { f.StringArrayVar(&opts.InsensitiveExcludeFiles, "iexclude-file", nil, "same as --exclude-file but ignores casing of `file`names in patterns") } +func (opts *excludePatternOptions) Empty() bool { + return len(opts.Excludes) == 0 && len(opts.InsensitiveExcludes) == 0 && len(opts.ExcludeFiles) == 0 && len(opts.InsensitiveExcludeFiles) == 0 +} + func collectExcludePatterns(opts excludePatternOptions) ([]RejectByNameFunc, error) { var fs []RejectByNameFunc // add patterns from file