Skip to content

fix(copy-ignored): let directory patterns cover files inside the directory - #4406

Merged
max-sixty merged 1 commit into
mainfrom
nightly/clean-37895028399
Oct 10, 2026
Merged

max-sixty merged 1 commit into
mainfrom
nightly/clean-37895028399

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

A .worktreeinclude or [step.copy-ignored].exclude pattern naming a directory (config/) now covers the ignored files inside it, as the same line would in .gitignore. Before, it silently missed any ignored file that shares its directory with tracked files.

The cause: git ls-files --ignored -o --directory collapses a directory to config/ only when everything in it is ignored. With a tracked config/app.yml beside an ignored config/local.yml, it lists config/local.yml itself, and both matchers in list_and_filter_ignored_entries used Gitignore::matched, which tests only the path given. As a result:

  • .worktreeinclude = config/ → wt step copy-ignored reported "No matching files to copy".
  • exclude = ["config/"] → config/local.yml was copied anyway.

Both matchers now call matched_path_or_any_parents on the worktree-relative path. A negation on the file itself (!config/local.yml) still wins, because the file is checked before its parents. wt step promote uses the same include filter, so it now swaps those files as well, which is what its docs describe ("filtered with .worktreeinclude").

Two regression tests in step_copy_ignored.rs cover the include and exclude cases. Both failed before the change, and they pass with it alongside the rest of step_copy_ignored and step_promote. The exceptions are two existing tests that also fail on main in this sandbox: one depends on umask (expects 0644, gets 0664) and one creates a Unix socket.

…ctory

`.worktreeinclude` and `[step.copy-ignored].exclude` matched each entry
from `git ls-files --directory` with `Gitignore::matched`, which tests only
the path itself. Git lists an ignored file individually when its directory
also holds tracked files, so a `config/` pattern never reached
`config/local.yml`: an include pattern copied nothing, and an exclude
pattern let the file through. Matching now walks the entry's parents, as
`.gitignore` does. `wt step promote` shares the include filter.
@worktrunk-bot worktrunk-bot added the nightly-cleanup Issues found by nightly code quality sweep label Oct 9, 2026
@max-sixty
max-sixty merged commit f1ddabe into main Oct 10, 2026
37 of 47 checks passed
@max-sixty
max-sixty deleted the nightly/clean-37895028399 branch October 10, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nightly-cleanup Issues found by nightly code quality sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants