Repository navigation
fix(engine): register nested dir-merge as per-directory rule, not eager merge - #5902
Merged
Merged
Conversation
…er merge When a per-directory merge file contained a `dir-merge` or `:` short-form directive, oc-rsync eagerly loaded the referenced file from the enclosing file's parent directory instead of registering a new per-directory merge rule for subsequent subdirectory traversal. This diverged from upstream exclude.c:1419-1428 and caused over-deletion in fixtures like the upstream testsuite's exclude-lsh, where `bar/.filt` declares `dir-merge .filt2` but the actual `.filt2` files live in subdirectories such as `bar/down/to/`. The eager load failed silently and the per-dir rule was never enforced inside those subdirectories. Split the parsed AST so `merge`/`.` keeps the eager-load semantics in a `Merge` variant while `dir-merge`/`per-dir`/`:` produces a new `DirMerge` variant that carries only the bare filename. Loading a per-directory merge file now accumulates these nested directives into `DirMergeEntries.nested_dir_merges`. The CopyContext maintains a per-directory stack of `DynamicDirMergeFrame`s, inherited via `DirectoryFilterGuard`, that record the active per-directory rules and the segments / markers loaded for each visited subdirectory. Filter evaluation applies the dynamic top-of-stack segments before the static program so child-directory rules override inherited parent rules with first-match-wins semantics, matching upstream check_filter(). Adds a parse-side unit test confirming both forms emit `DirMerge` and an integration test mirroring the exclude-lsh fixture: a source tree with `bar/.filt` declaring `dir-merge .filt2` plus `bar/baz/.filt2` with `- *.deep` correctly excludes `bar/baz/file5.deep` from the transfer.
oferchen
force-pushed
the
fix/uts-dd-exclude-1-dir-merge-nested
branch
from
June 17, 2026 19:34
8873ac1 to
19969a3
Compare
1 of 2 tasks
oferchen
added a commit
that referenced
this pull request
Jun 17, 2026
Two unrelated breaks landed on master after #5899 and #5902 and now block every PR: 1. `core::client::remote::ssh_transfer` still called `flags::build_wire_format_rules` with one argument after #5899 added a `delete_excluded: bool` parameter (`embedded_ssh_transfer.rs` was updated; the two call sites in `ssh_transfer.rs` were missed). Pass `config.delete_excluded()` to match the wire-format contract. 2. `engine::local_copy::context_impl::transfer` used `Vec::extend(other.drain(..))` instead of `Vec::append(&mut other)` after #5902, which trips `clippy::extend-with-drain` under `-D warnings`. Switch to `append`. These are minimal mechanical fixes; no behaviour change.
1 of 3 tasks
oferchen
added a commit
that referenced
this pull request
Jun 17, 2026
* fix(engine,core): unblock master CI after #5899 + #5902 regressions PR #5902 introduced a `clippy::extend-with-drain` lint violation in the nested dir-merge wiring at transfer.rs:187. PR #5899 widened `build_wire_format_rules` to take a `delete_excluded: bool` parameter but missed the SSH push/pull call sites in ssh_transfer.rs (E0061). Both fail the master fmt+clippy and Build cells, blocking every open PR. - engine/.../transfer.rs: replace `extend(.drain(..))` with `append(&mut)`. - core/.../ssh_transfer.rs: pass `config.delete_excluded()` at both call sites. * fix(core): wire delete_excluded through async_ssh_transport build_*_server_config * fix(tests): clippy assertions-on-constants + manual-contains lints - transfer test: wrap compile-time invariants in `const _: () = assert!(...)` - cli verbose test: use `lines.contains(&"only.txt")` over iter().any() * fix(tests): convert OsString args to String for find_flag_string helper
2 of 4 tasks
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…er merge (#5902) When a per-directory merge file contained a `dir-merge` or `:` short-form directive, oc-rsync eagerly loaded the referenced file from the enclosing file's parent directory instead of registering a new per-directory merge rule for subsequent subdirectory traversal. This diverged from upstream exclude.c:1419-1428 and caused over-deletion in fixtures like the upstream testsuite's exclude-lsh, where `bar/.filt` declares `dir-merge .filt2` but the actual `.filt2` files live in subdirectories such as `bar/down/to/`. The eager load failed silently and the per-dir rule was never enforced inside those subdirectories. Split the parsed AST so `merge`/`.` keeps the eager-load semantics in a `Merge` variant while `dir-merge`/`per-dir`/`:` produces a new `DirMerge` variant that carries only the bare filename. Loading a per-directory merge file now accumulates these nested directives into `DirMergeEntries.nested_dir_merges`. The CopyContext maintains a per-directory stack of `DynamicDirMergeFrame`s, inherited via `DirectoryFilterGuard`, that record the active per-directory rules and the segments / markers loaded for each visited subdirectory. Filter evaluation applies the dynamic top-of-stack segments before the static program so child-directory rules override inherited parent rules with first-match-wins semantics, matching upstream check_filter(). Adds a parse-side unit test confirming both forms emit `DirMerge` and an integration test mirroring the exclude-lsh fixture: a source tree with `bar/.filt` declaring `dir-merge .filt2` plus `bar/baz/.filt2` with `- *.deep` correctly excludes `bar/baz/file5.deep` from the transfer.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
* fix(engine,core): unblock master CI after #5899 + #5902 regressions PR #5902 introduced a `clippy::extend-with-drain` lint violation in the nested dir-merge wiring at transfer.rs:187. PR #5899 widened `build_wire_format_rules` to take a `delete_excluded: bool` parameter but missed the SSH push/pull call sites in ssh_transfer.rs (E0061). Both fail the master fmt+clippy and Build cells, blocking every open PR. - engine/.../transfer.rs: replace `extend(.drain(..))` with `append(&mut)`. - core/.../ssh_transfer.rs: pass `config.delete_excluded()` at both call sites. * fix(core): wire delete_excluded through async_ssh_transport build_*_server_config * fix(tests): clippy assertions-on-constants + manual-contains lints - transfer test: wrap compile-time invariants in `const _: () = assert!(...)` - cli verbose test: use `lines.contains(&"only.txt")` over iter().any() * fix(tests): convert OsString args to String for find_flag_string helper
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.
Summary
UTS-DD-exclude.1 (#4526). A per-directory merge file containing
dir-mergeor
:short-form was treated like a plainmerge: oc-rsync eagerly loadedthe referenced filter file from the enclosing file's parent directory. The
upstream behavior (
exclude.c:1419-1428) is to register the referencedfilename as a NEW per-directory rule that gets looked up in each
subsequently entered subdirectory.
Concrete divergence reproduced from the upstream testsuite
exclude-lshfixture:
bar/.filtcontainsdir-merge .filt2and the per-subdir ruleslive at
bar/down/to/.filt2,bar/down/to/foo/.filt2,bar/down/to/bar/.filt2. The eager load looked forbar/.filt2, whichdoes not exist; the per-dir rule was never enforced, and oc-rsync
over-deleted files such as
bar/down/to/bar/baz/file5.deepthat theper-dir
- *.deeprule should have protected.merge/.keepMerge(eager);dir-merge/per-dir/:emit a new
DirMergevariant carrying the bare filename.DirMergeEntriesnow collects nested per-dir registrations innested_dir_mergesinstead of recursing eagerly.CopyContextmaintains a per-directory stack ofDynamicDirMergeFrames scoped byDirectoryFilterGuard. Onenter_directory_for_path, inherited active rules are resolved againstthe current directory, segments and markers are collected, and any
freshly-registered
dir-mergerules become active for subdirectories.giving child-directory rules first-match priority over inherited parent
rules per
exclude.c:check_filter().Test plan
crates/engine/src/local_copy/dir_merge/parse/confirmparse_dir_merge_directiveand the:short form both emitParsedFilterDirective::DirMerge.nested_dir_merge_registers_per_directory_ruleincrates/engine/src/local_copy/tests/filters_runtime.rsbuilds asource tree with
bar/.filtcontainingdir-merge .filt2andbar/baz/.filt2containing- *.deep, then assertsbar/baz/file5.deepis excluded from the transfer whilebar/baz/keep.txtis copied.cargo fmt --allclean.Refs upstream-src/rsync-3.4.4/exclude.c:1419-1428,
testsuite/exclude-lsh.test.