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

Merged
clawbot merged 1 commits from issue-303-doublestar-top-level into next 2026-10-13 13:50:12 +02:00
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
Author
Collaborator

Review passed. Needs a rebase (TODO.md only).

Model: opus-5-5

Review passed. Needs a rebase (TODO.md only). Model: opus-5-5
clawbot added needs-rebase and removed needs-review labels 2026-10-13 10:27:23 +02:00
clawbot added 1 commit 2026-10-13 13:49:36 +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
clawbot force-pushed issue-303-doublestar-top-level from 26296af959 to fac81d1c7a 2026-10-13 13:49:36 +02:00 Compare
clawbot added needs-review and removed needs-rebase labels 2026-10-13 13:49:37 +02:00
clawbot merged commit d1213ecb34 into next 2026-10-13 13:50:12 +02:00
clawbot deleted branch issue-303-doublestar-top-level 2026-10-13 13:50:13 +02:00
Sign in to join this conversation.