From fbf8073dfc455f8739218b3aed76769875b82b25 Mon Sep 17 00:00:00 2001 From: Mikael Berthe Date: Sun, 24 Jun 2018 19:20:59 +0200 Subject: [PATCH] Fix find -i (case-insensitive search) --- changelog/unreleased/pull-1861 | 6 ++++++ cmd/restic/cmd_find.go | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 changelog/unreleased/pull-1861 diff --git a/changelog/unreleased/pull-1861 b/changelog/unreleased/pull-1861 new file mode 100644 index 000000000..2ccb4d5f6 --- /dev/null +++ b/changelog/unreleased/pull-1861 @@ -0,0 +1,6 @@ +Bugfix: Fix case-insensitive search with restic find + +We've fixed the behavior for `restic find -i PATTERN`, which was +broken in v0.9.1. + +https://github.com/restic/restic/pull/1861 diff --git a/cmd/restic/cmd_find.go b/cmd/restic/cmd_find.go index d21453859..86da03994 100644 --- a/cmd/restic/cmd_find.go +++ b/cmd/restic/cmd_find.go @@ -198,12 +198,12 @@ func (f *Finder) findInSnapshot(ctx context.Context, sn *restic.Snapshot) error return false, nil } - name := node.Name + normalizedNodepath := nodepath if f.pat.ignoreCase { - name = strings.ToLower(name) + normalizedNodepath = strings.ToLower(nodepath) } - foundMatch, err := filter.Match(f.pat.pattern, nodepath) + foundMatch, err := filter.Match(f.pat.pattern, normalizedNodepath) if err != nil { return false, err } @@ -213,7 +213,7 @@ func (f *Finder) findInSnapshot(ctx context.Context, sn *restic.Snapshot) error errIfNoMatch error ) if node.Type == "dir" { - childMayMatch, err := filter.ChildMatch(f.pat.pattern, nodepath) + childMayMatch, err := filter.ChildMatch(f.pat.pattern, normalizedNodepath) if err != nil { return false, err }