Skip to content

fix(cli): CVS !-clear semantics and --from0 filter files - #6708

Merged
oferchen merged 1 commit into
masterfrom
fix/filter-cvsignore-from0
Jul 17, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/filter-cvsignore-from0

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

Two filter-subsystem parity fixes in crates/cli, matching upstream rsync 3.4.4 (exclude.c). Two related items are deferred because their real fix sites live in crates/core.

Done

#217 - CVS .cvsignore / $CVSIGNORE ! handling

Mirrors upstream parse_rule_tok. In a FILTRULE_NO_PREFIXES CVS list, a leading ! tentatively sets FILTRULE_CLEAR_LIST (exclude.c:1122-1124), but len > 1 clears it again (exclude.c:1315-1323), so:

  • !foo is a literal exclude of a file named !foo (the ! stays in the pattern because NO_PREFIXES never advances past it) - not a removal of a prior foo exclude.
  • A bare ! (len == 1) keeps FILTRULE_CLEAR_LIST, and pop_filter_list (exclude.c:1399) wipes the whole shared cvs_filter_list, including the built-in default_cvsignore() patterns.

The previous code invented a remove_cvs_pattern path (so !foo deleted a prior exclude) and cleared a per-source local buffer (so built-in defaults survived a bare !). Both are removed; ~/.cvsignore and $CVSIGNORE now parse into the shared accumulator so a bare ! wipes the built-ins too.

Files: crates/cli/src/frontend/filter_rules/cvs.rs; integration test in transfer_request_with_filter.rs rewritten to assert the correct wipe-includes-builtins behavior.

#218 - --from0 / eol_nulls for filter FILES

Upstream parse_filter_file splits on NUL when eol_nulls is set (exclude.c:1501: if (eol_nulls? !ch : (ch=='\n'||ch=='\r')) break), so -0/--from0 makes --exclude-from / --include-from files NUL-delimited. The reader hardcoded read_until(b'\n'). The existing --from0 flag is now threaded through FilterInputs -> apply_filters -> append_filter_rules_from_files -> load_filter_file_patterns -> read_filter_patterns, which splits on NUL and treats embedded newlines as literal pattern bytes.

Files: crates/cli/src/frontend/filter_rules/sources.rs, execution/drive/filters.rs, execution/drive/workflow/run.rs, frontend/mod.rs.

Deferred (fix site outside crates/cli)

  • Add helper for classifying negotiation prologues #219 - CVS :C/-C wire placement + proto>=29 gate. Upstream injects :C/-C inside send_filter_list / recv_filter_list with am_sender/protocol ordering; the client-receiver adds them local-only, never on the wire, and gates :C on proto>=29 (exclude.c:1644-1698). In this codebase the wire send/recv path is build_wire_format_rules in crates/core/src/client/remote/flags.rs (core), not cli. Skipped per scope guard.
  • Guard negotiation buffer growth against underflow #222 - delete-excluded no-prefixes dir-merge elision. Upstream send_rules elides a no-prefixes per-dir-merge under delete_excluded (exclude.c:1609-1612). The logic (apply_implicit_sender_side_for_delete_excluded and the wire elision in build_wire_format_rules) is in crates/core/src/client/config/filters.rs and crates/core/src/client/remote/flags.rs (core), not cli. Skipped per scope guard.

Verification

  • cargo fmt --all -- --check: clean.
  • cargo clippy -p cli --all-features --all-targets --no-deps -- -D warnings: clean.
  • Targeted cargo nextest run -p cli over filter/cvs/exclude/include tests: 433 passed.

#217 CVS `.cvsignore`/$CVSIGNORE `!` handling: mirror upstream
parse_rule_tok (exclude.c:1122-1124, 1315-1323). In a NO_PREFIXES CVS
list a leading `!` tentatively sets FILTRULE_CLEAR_LIST, but len>1 clears
it, so `!foo` is a LITERAL exclude of a file named `!foo` (not a removal
of a prior `foo` exclude). A bare `!` (len==1) keeps CLEAR_LIST and
pop_filter_list (exclude.c:1399) wipes the WHOLE shared cvs list,
including the built-in defaults. Drop the invented remove-pattern path
and parse ~/.cvsignore and $CVSIGNORE into the shared accumulator.

#218 --from0/eol_nulls for filter files: honor `--from0`/`-0` when
reading `--exclude-from`/`--include-from` files so records split on NUL,
mirroring parse_filter_file (exclude.c:1501). Embedded newlines become
literal pattern bytes.

Deferred (fix site outside crates/cli, occupied by other in-flight PRs):
#219 CVS :C/-C wire placement and proto>=29 gate live in the wire
send/recv path (core build_wire_format_rules). #222 delete-excluded
no-prefixes dir-merge elision lives in core
apply_implicit_sender_side_for_delete_excluded / build_wire_format_rules.
@github-actions github-actions Bot added the bug Something isn't working label Jul 17, 2026
@oferchen
oferchen merged commit ae4f82b into master Jul 17, 2026
63 checks passed
@oferchen
oferchen deleted the fix/filter-cvsignore-from0 branch July 17, 2026 20:34
oferchen added a commit that referenced this pull request Aug 24, 2026
#217 CVS `.cvsignore`/$CVSIGNORE `!` handling: mirror upstream
parse_rule_tok (exclude.c:1122-1124, 1315-1323). In a NO_PREFIXES CVS
list a leading `!` tentatively sets FILTRULE_CLEAR_LIST, but len>1 clears
it, so `!foo` is a LITERAL exclude of a file named `!foo` (not a removal
of a prior `foo` exclude). A bare `!` (len==1) keeps CLEAR_LIST and
pop_filter_list (exclude.c:1399) wipes the WHOLE shared cvs list,
including the built-in defaults. Drop the invented remove-pattern path
and parse ~/.cvsignore and $CVSIGNORE into the shared accumulator.

#218 --from0/eol_nulls for filter files: honor `--from0`/`-0` when
reading `--exclude-from`/`--include-from` files so records split on NUL,
mirroring parse_filter_file (exclude.c:1501). Embedded newlines become
literal pattern bytes.

Deferred (fix site outside crates/cli, occupied by other in-flight PRs):
#219 CVS :C/-C wire placement and proto>=29 gate live in the wire
send/recv path (core build_wire_format_rules). #222 delete-excluded
no-prefixes dir-merge elision lives in core
apply_implicit_sender_side_for_delete_excluded / build_wire_format_rules.
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