Make a leading **/ in an exclude pattern match at the top level #335

Open
clawbot wants to merge 1 commits from issue-303-doublestar-top-level into next
Collaborator

Fixes #303.

What was wrong: an exclude pattern starting with **/ needed a / before the name. **/node_modules and **/*.pyc, the patterns config.example.yml uses, excluded sub/node_modules and sub/y.pyc but backed up node_modules/ and x.pyc directly under the snapshot path.

What changed: when an unanchored pattern is compiled, a leading **/ is dropped. An unanchored pattern already matches at every depth, so the pattern keeps its nested matches and, as in gitignore, now also matches at the top level. Two tests cover a directory pattern and a file pattern, each matched at the top level and nested.

Judgement call: an anchored /**/x is unchanged and still misses a top-level x; the issue covers patterns that start with **/.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/vaultik/issues/303. **What was wrong:** an exclude pattern starting with `**/` needed a `/` before the name. `**/node_modules` and `**/*.pyc`, the patterns `config.example.yml` uses, excluded `sub/node_modules` and `sub/y.pyc` but backed up `node_modules/` and `x.pyc` directly under the snapshot path. **What changed:** when an unanchored pattern is compiled, a leading `**/` is dropped. An unanchored pattern already matches at every depth, so the pattern keeps its nested matches and, as in gitignore, now also matches at the top level. Two tests cover a directory pattern and a file pattern, each matched at the top level and nested. Judgement call: an anchored `/**/x` is unchanged and still misses a top-level `x`; the issue covers patterns that start with `**/`. Model: opus-5-5
clawbot added the needs-review label 2026-10-13 04:13:58 +02:00
clawbot self-assigned this 2026-10-13 04:13:58 +02:00
clawbot added 1 commit 2026-10-13 04:13:58 +02:00
An unanchored exclude pattern such as **/node_modules or **/*.pyc
needed a / before the name, so it excluded sub/node_modules and
sub/y.pyc but backed up node_modules/ and x.pyc directly under the
snapshot path. An unanchored pattern already matches at every depth,
so the leading **/ is now dropped when the pattern is compiled and,
as in gitignore, the pattern matches the top level too.

Judgement call: an anchored /**/x is left as it was; the issue covers
patterns that start with **/.

Model: opus-5-5
Some checks are pending
check / check (push) Waiting to run
This pull request has changes conflicting with the target branch.
  • TODO.md
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin issue-303-doublestar-top-level:issue-303-doublestar-top-level
git checkout issue-303-doublestar-top-level
Sign in to join this conversation.