Repository navigation
fix(copy-ignored): let directory patterns cover files inside the directory - #4406
Merged
Merged
Conversation
…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.
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
.worktreeincludeor[step.copy-ignored].excludepattern 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 --directorycollapses a directory toconfig/only when everything in it is ignored. With a trackedconfig/app.ymlbeside an ignoredconfig/local.yml, it listsconfig/local.ymlitself, and both matchers inlist_and_filter_ignored_entriesusedGitignore::matched, which tests only the path given. As a result:.worktreeinclude=config/→wt step copy-ignoredreported "No matching files to copy".exclude = ["config/"]→config/local.ymlwas copied anyway.Both matchers now call
matched_path_or_any_parentson 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 promoteuses 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.rscover the include and exclude cases. Both failed before the change, and they pass with it alongside the rest ofstep_copy_ignoredandstep_promote. The exceptions are two existing tests that also fail onmainin this sandbox: one depends on umask (expects 0644, gets 0664) and one creates a Unix socket.