Skip to content

fix(filters): wire :C cvs_mode + default empty pattern to .cvsignore - #5817

Merged
oferchen merged 2 commits into
masterfrom
fix/uts-filter-scope-fall-through
Jun 17, 2026
Merged

oferchen merged 2 commits into
masterfrom
fix/uts-filter-scope-fall-through

Conversation

@oferchen

@oferchen oferchen commented Jun 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes the upstream exclude / exclude-lsh testsuite failures triggered by -f:C -f-C --delete-excluded and a per-directory mid/.filt containing a bare :C line. The original PR title (filter scope fall-through) described an intermediate symptom; the actual root causes are in the :C modifier parse path and the wire-rule -> DirMergeConfig conversion. This PR is honest about that scope.

This PR does not touch --files-from. That was lumped in incorrectly with the previous title; if there is a real --files-from issue it will land separately.

What this PR does

  • Per-directory .filt containing :C (now): parser falls through to .cvsignore instead of erroring as "unrecognized filter rule", and RuleModifiers::apply propagates cvs_mode onto the resulting FilterRule. Mirrors upstream exclude.c:1324 (allow empty pattern when FILTRULE_CVS_IGNORE is set) and exclude.c:1404-1408 (default to .cvsignore). [PR fix(filters): parse :C modifier on per-directory merge rules for CVS-ignore #5842 already landed this piece on this branch; this PR completes the wire side.]
  • -f:C over remote shell (now): the CLI parser already maps :C to a DirMerge spec with the right semantics, but build_wire_format_rules had no way to forward the C modifier because DirMergeOptions did not track it. Add a cvs_mode flag to DirMergeOptions, set it from the CLI parse_merge_modifiers C branch, and forward it as cvs_exclude=true on the wire so the remote sender sees the full :C rule.
  • Wire rule with cvs_exclude=true and empty pattern (now): wire_rule_to_dir_merge_config substitutes .cvsignore as the default filename instead of producing a DirMergeConfig with an empty filename that silently disables per-directory .cvsignore lookup. Mirrors upstream exclude.c:1404-1408.

Upstream references

  • rsync-3.4.4/exclude.c:1248-1255 - C modifier sets FILTRULE_NO_PREFIXES | FILTRULE_WORD_SPLIT | FILTRULE_NO_INHERIT | FILTRULE_CVS_IGNORE.
  • rsync-3.4.4/exclude.c:1324 - empty pattern allowed only when FILTRULE_CVS_IGNORE is set.
  • rsync-3.4.4/exclude.c:1404-1408 - merge/dir-merge with empty pattern defaults to .cvsignore.
  • rsync-3.4.4/testsuite/exclude.test:86-88 (and exclude-lsh.test via symlink) - failing fixture: mid/.filt contains a bare :C line; the wrapping run drives -f dir-merge_.filt -f:C -f-C.

Scope explicitly NOT in this PR

  • --files-from (will be addressed in a separate PR if a real regression is identified).
  • The non-inheriting outer-scope fall-through commit from the earlier history of this branch (869c796b) is preserved; the new commits stack on top of it.

Test plan

  • cargo fmt --all -- --check
  • CI: fmt+clippy, nextest (stable), Windows, macOS, Linux musl
  • CI: upstream testsuite exclude and exclude-lsh
  • New regression tests:
    • wire_rule_to_dir_merge_config_empty_pattern_defaults_to_cvsignore (crates/transfer/src/generator/filters.rs) - empty wire pattern with cvs_exclude=true -> .cvsignore filename.
    • dir_merge_cvs_mode_forwards_cvs_exclude_flag (crates/core/src/client/remote/flags.rs) - locally parsed :C DirMerge round-trips cvs_exclude=true to the wire.
    • dir_merge_options_cvs_mode_round_trip (crates/engine/src/local_copy/filter_program/options.rs) - DirMergeOptions::cvs_mode accessor pair is stable.
    • parse_merge_modifiers_cvsignore augmented with is_cvs_mode() assertion (crates/cli/src/frontend/filter_rules/parsing/merge.rs).
  • PR fix(filters): parse :C modifier on per-directory merge rules for CVS-ignore #5842's regression tests for the bare :C parse path remain in place (crates/filters/src/merge/tests.rs).

@oferchen

Copy link
Copy Markdown
Owner Author

NACK — testsuite/exclude.test and exclude-lsh.test still show FAIL on this branch.

Root cause: scope_has_deletion_match() calls filter_set.has_deletion_rule_match(path, is_dir) without enabling descendant-check, while the Transfer arm correctly skips descendants. For Deletion context, descendants MUST be checked (an excluded directory's descendants are also excluded for deletion purposes).

Precise fix: in crates/filters/src/set.rs has_deletion_rule_match, the call to self.inner.has_matching_rule needs to pass check_descendants=true (or equivalent) — Deletion's semantic is opposite to Transfer's for descendants. Confirm by re-running exclude.test on the branch after the change.

@oferchen
oferchen force-pushed the fix/uts-filter-scope-fall-through branch from 912451b to 869c796 Compare June 16, 2026 14:08
@oferchen
oferchen marked this pull request as draft June 16, 2026 17:57
@oferchen

Copy link
Copy Markdown
Owner Author

Validation failed — converted back to draft.

This PR claims to fix upstream testsuite test(s): exclude-lsh,exclude,files-from.

Latest upstream testsuite run on this PR's head: https://github.com/oferchen/rsync/actions/runs/27635559609/job/81721703883

The workflow check shows SUCCESS only because the job and step are both marked continue-on-error: true. The actual per-test result inside the workflow log is:

upstream testsuite	Run upstream testsuite	2026-06-16T17:38:39.9510960Z FAIL    exclude-lsh  (exit 1)
upstream testsuite	Run upstream testsuite	2026-06-16T17:38:41.0973348Z FAIL    exclude  (exit 1)
upstream testsuite	Run upstream testsuite	2026-06-16T17:38:41.1943899Z FAIL    files-from  (exit 1)

The claimed test still FAILs. Do not re-ready until the per-test log shows PASS for every claimed test, and no other UTS tests regress.

@oferchen oferchen changed the title fix(filters): fall through to outer scopes when non-inheriting scope has no match fix(filters): wire :C cvs_mode + default empty pattern to .cvsignore Jun 16, 2026
@oferchen
oferchen force-pushed the fix/uts-filter-scope-fall-through branch 4 times, most recently from 9be78f0 to 744ef63 Compare June 17, 2026 09:43
oferchen added 2 commits June 17, 2026 15:28
…has no match

Per-directory filter scope evaluation could short-circuit on a synthetic
`pattern/**` descendant matcher (compiled for anchored excludes like
`- /bar`) and return the inner scope's traversal-mode decision before
the outer scope's real user-written rule could fire.

Replace the previous `has_matching_rule` helper - which called the
public `allows_during_traversal` and `allows_deletion` and so saw the
descendant optimisation - with two context-aware predicates that only
consider real direct matchers. This mirrors upstream
`exclude.c:rule_matches()`, which has no descendant matching at all -
descendant exclusion is a side effect of the sender walk not descending
into excluded directories. Both the Transfer (`allows`) and Deletion
(`allows_deletion`) paths now fall through to outer scopes when the
current scope contains no real rule matching the path, and continue to
honour protect/risk rules on the deletion side.

Add regression coverage that pins the inner-scope descendant fall-
through, root-level rule propagation through silent per-dir scopes,
`:C`-style non-inheriting scope fall-through, and the symmetric
deletion-side behaviour.
…o .cvsignore

PR #5842 fixed the merge-file parser to accept a bare `:C` line by
adding `cvs_mode` to `FilterRule`. Two related wire-side gaps still let
the upstream `exclude` / `exclude-lsh` testsuite fail when `-f:C -f-C`
is invoked over remote shell:

- `build_wire_format_rules` ignored the `C` modifier when encoding a
  DirMerge spec, because `DirMergeOptions` had no dedicated cvs-mode
  bit. The CLI parsed `:C` correctly, but `cvs_exclude` was always
  false on the wire, so the remote sender never saw the `C` flag.
- `wire_rule_to_dir_merge_config` did not implement upstream
  `exclude.c:1404-1408`'s "empty pattern defaults to `.cvsignore`"
  fallback, so a wire rule like `:C ` (cvs_exclude set, no pattern)
  produced a `DirMergeConfig` with an empty filename and silently
  disabled per-directory `.cvsignore` lookup.

Add a `cvs_mode` field to `DirMergeOptions` with `cvs_mode()` /
`is_cvs_mode()` accessors, set it from the CLI `parse_merge_modifiers`
`C` branch, forward it as `cvs_exclude=true` in `build_wire_format_rules`,
and substitute `.cvsignore` as the default pattern inside
`wire_rule_to_dir_merge_config` when the wire rule has cvs_exclude set
with no pattern.
@oferchen
oferchen force-pushed the fix/uts-filter-scope-fall-through branch from 744ef63 to 3ba8a27 Compare June 17, 2026 12:28
@oferchen
oferchen marked this pull request as ready for review June 17, 2026 12:28
@oferchen
oferchen merged commit 72a03f8 into master Jun 17, 2026
8 of 9 checks passed
@oferchen
oferchen deleted the fix/uts-filter-scope-fall-through branch June 17, 2026 12:29
oferchen added a commit that referenced this pull request Aug 24, 2026
`:C` (and `.C`) with empty pattern in a locally-parsed filter file
fails with "unrecognized filter rule" because the short-form parser
short-circuits on empty pattern before checking the cvs_mode
modifier. Upstream `exclude.c:1404-1408` substitutes `.cvsignore`
when the merge rule has cvs_mode and an empty pattern.

The wire-format path (`wire_rule_to_dir_merge_config`) handles this
correctly. The gap is local-only: `RuleModifiers::cvs_mode` is set
in the parser but never propagated to `FilterRule`, so consumers
that turn parsed dir-merge rules into `DirMergeConfig` lose the
signal to call `with_cvs_mode(true)`.

Captures the precise parse failure, upstream references, fix spec
(4 edits ~140 LoC across filters/cli/engine), and unit test
scaffolding. Tracks UTS-V4.B. Distinct from PR #5817 which addresses
post-load scope fall-through, not the pre-load parser reject.
oferchen added a commit that referenced this pull request Aug 24, 2026
…5817)

* fix(filters): fall through to outer scopes when non-inheriting scope has no match

Per-directory filter scope evaluation could short-circuit on a synthetic
`pattern/**` descendant matcher (compiled for anchored excludes like
`- /bar`) and return the inner scope's traversal-mode decision before
the outer scope's real user-written rule could fire.

Replace the previous `has_matching_rule` helper - which called the
public `allows_during_traversal` and `allows_deletion` and so saw the
descendant optimisation - with two context-aware predicates that only
consider real direct matchers. This mirrors upstream
`exclude.c:rule_matches()`, which has no descendant matching at all -
descendant exclusion is a side effect of the sender walk not descending
into excluded directories. Both the Transfer (`allows`) and Deletion
(`allows_deletion`) paths now fall through to outer scopes when the
current scope contains no real rule matching the path, and continue to
honour protect/risk rules on the deletion side.

Add regression coverage that pins the inner-scope descendant fall-
through, root-level rule propagation through silent per-dir scopes,
`:C`-style non-inheriting scope fall-through, and the symmetric
deletion-side behaviour.

* fix(filters): forward :C cvs_mode on wire and default empty pattern to .cvsignore

PR #5842 fixed the merge-file parser to accept a bare `:C` line by
adding `cvs_mode` to `FilterRule`. Two related wire-side gaps still let
the upstream `exclude` / `exclude-lsh` testsuite fail when `-f:C -f-C`
is invoked over remote shell:

- `build_wire_format_rules` ignored the `C` modifier when encoding a
  DirMerge spec, because `DirMergeOptions` had no dedicated cvs-mode
  bit. The CLI parsed `:C` correctly, but `cvs_exclude` was always
  false on the wire, so the remote sender never saw the `C` flag.
- `wire_rule_to_dir_merge_config` did not implement upstream
  `exclude.c:1404-1408`'s "empty pattern defaults to `.cvsignore`"
  fallback, so a wire rule like `:C ` (cvs_exclude set, no pattern)
  produced a `DirMergeConfig` with an empty filename and silently
  disabled per-directory `.cvsignore` lookup.

Add a `cvs_mode` field to `DirMergeOptions` with `cvs_mode()` /
`is_cvs_mode()` accessors, set it from the CLI `parse_merge_modifiers`
`C` branch, forward it as `cvs_exclude=true` in `build_wire_format_rules`,
and substitute `.cvsignore` as the default pattern inside
`wire_rule_to_dir_merge_config` when the wire rule has cvs_exclude set
with no pattern.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant