Skip to content

fix: correct -FF filter shortcut to match upstream rsync behavior - #3082

Merged
oferchen merged 1 commit into
masterfrom
fix/merge-filter-ff-shortcut
Mar 31, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/merge-filter-ff-shortcut

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Fixes push_rsync_filter_shortcut() in crates/cli/src/frontend/filter_rules/arguments.rs to match upstream rsync options.c:1589-1598
  • First -F: adds dir-merge /.rsync-filter (anchored merge rule)
  • Second -F: adds exclude .rsync-filter (exclude filter files from transfer)
  • Third+ -F: ignored (matching upstream switch(++F_option_cnt) behavior)
  • Removes oc:merge-filter from KNOWN_FAILURES in interop test harness

Bug: Previously, first -F added both rules, and second -F added incorrect dir-merge .rsync-filter (unanchored, wrong rule type).

Test plan

  • Updated unit tests to match corrected behavior
  • Added test for third -F being ignored
  • CI interop oc:merge-filter test should now pass

The push_rsync_filter_shortcut() function incorrectly handled the -F
flag. It added both dir-merge and exclude rules on the first -F, then
added a wrong dir-merge rule on the second -F.

Upstream rsync (options.c:1589-1598) behavior:
- First -F: `: /.rsync-filter` (dir-merge, anchored to transfer root)
- Second -F: `- .rsync-filter` (exclude filter files from transfer)
- Third+ -F: ignored

This fix matches upstream exactly and removes oc:merge-filter from
KNOWN_FAILURES in the interop test harness.
@github-actions github-actions Bot added the bug Something isn't working label Mar 31, 2026
@oferchen
oferchen merged commit 09d3fff into master Mar 31, 2026
26 of 44 checks passed
@oferchen
oferchen deleted the fix/merge-filter-ff-shortcut branch March 31, 2026 15:30
oferchen added a commit that referenced this pull request Apr 3, 2026
The integration tests in collect.rs expected 3 rules from -FF (the old
broken behavior), but upstream rsync options.c:1589-1598 produces exactly
2 rules: dir-merge /.rsync-filter (first -F) and exclude .rsync-filter
(second -F). The implementation was correct after PR #3082; only the
tests were wrong.
oferchen added a commit that referenced this pull request Apr 3, 2026
The integration tests in collect.rs expected 3 rules from -FF (the old
broken behavior), but upstream rsync options.c:1589-1598 produces exactly
2 rules: dir-merge /.rsync-filter (first -F) and exclude .rsync-filter
(second -F). The implementation was correct after PR #3082; only the
tests were wrong.
oferchen added a commit that referenced this pull request Apr 3, 2026
…3084)

* fix: correct batch interop framing for read-batch and batch flags

- Add NDX-driven replay loop in replay.rs matching upstream receiver.c:
  reads NDX + iflags + sum_head + delta tokens + file checksum per file,
  with NDX_DONE phase transitions (proto >= 29 supports phase 2 redo)
- Add missing preserve_devices and preserve_acls to BatchFlags in both
  batch_support.rs (remote path) and batch.rs (local path)

* fix: reorder batch write path to produce upstream-compatible stream

Upstream rsync's batch files are a tee of the protocol stream, which
naturally has all flist entries before any per-file delta data. Our
local copy path interleaves flist entries with file data during the
directory walk, producing an incorrectly ordered batch stream.

Buffer per-file delta data (NDX + iflags + sum_head + tokens +
checksum) in an in-memory Cursor<Vec<u8>> during the walk, then
append it to the batch file after the flist end marker. This produces
the correct upstream ordering: flist entries, flist end, then
NDX-framed delta data, then NDX_DONE phase markers.

Changes:
- Add batch_delta_buf, batch_flist_index, batch_ndx_codec to CopyContext
- Add begin_batch_file_delta() for NDX + iflags + sum_head preamble
- Redirect finalize_batch_file_delta() and capture_batch_whole_file()
  to write to delta buffer instead of batch writer
- Redirect flush_literal_chunk() and copy_matched_block() token writes
  to delta buffer
- Add flush_batch_delta_to_batch() to copy buffered data and write
  NDX_DONE markers after flist finalization
- Track flist index for correct NDX numbering in delta stream

* fix: update batch replay test to use NDX-framed delta format

The test_replay_with_compression_flag test was writing raw token data
without NDX framing, but replay.rs now expects the upstream NDX-driven
format (NDX + iflags + sum_head + delta tokens + file checksum +
NDX_DONE markers).

* fix: mirror upstream rsync asymmetric negotiation precedence

Upstream compat.c:332-363 parse_negotiate_str() uses asymmetric logic:
both sides converge on the first entry in the client's list that also
appears in the server's list. The server iterates the client's (remote)
list and breaks on first match; the client iterates its own local list
and picks the first item also in the server's (remote) list.

Our implementation incorrectly iterated the remote list for both roles,
which gave server-preference ordering when acting as client. This could
select a weaker algorithm (e.g., md5) when a stronger one (e.g., xxh128)
was mutually supported and preferred by the client.

* style: fix rustfmt formatting for map_err chains

* style: use contains() instead of iter().any() per clippy

* fix: exclude zstd/lz4 from compression auto-negotiation until interop-validated

When both sides support zstd (upstream 3.4.1 built with SUPPORT_ZSTD in CI),
auto-negotiation picks zstd. However our per-token zstd read codec does not
correctly parse upstream's compressed token stream, causing "Unknown frame
descriptor" errors.

Remove zstd and lz4 from the vstring advertisement list so auto-negotiation
falls back to zlibx. Explicit --compress-choice=zstd|lz4 still works since
it bypasses vstring exchange entirely (upstream compat.c:543).

Tasks #1379 (zstd) and #1380 (lz4) track re-enabling after wire format
validation.

* fix: use NDX-framed delta format in test_replay_with_token_deltas

The test was writing raw token-format delta data after the flist end
marker, but replay() expects NDX-framed data (NDX + iflags + sum_head
+ tokens + NDX_DONE). This caused a panic on .unwrap() across all CI
platforms.

Write proper NDX framing matching upstream receiver.c:recv_files()
format: file NDX, ITEM_TRANSFER iflags, zero sum_head (whole-file
transfer), token-format literal data, and two NDX_DONE markers for
the phase 1 and phase 2 transitions.

* style: fix rustfmt for write_token_literal call

* fix: correct -FF filter shortcut tests to match upstream behavior

The integration tests in collect.rs expected 3 rules from -FF (the old
broken behavior), but upstream rsync options.c:1589-1598 produces exactly
2 rules: dir-merge /.rsync-filter (first -F) and exclude .rsync-filter
(second -F). The implementation was correct after PR #3082; only the
tests were wrong.
oferchen added a commit that referenced this pull request May 1, 2026
)

The push_rsync_filter_shortcut() function incorrectly handled the -F
flag. It added both dir-merge and exclude rules on the first -F, then
added a wrong dir-merge rule on the second -F.

Upstream rsync (options.c:1589-1598) behavior:
- First -F: `: /.rsync-filter` (dir-merge, anchored to transfer root)
- Second -F: `- .rsync-filter` (exclude filter files from transfer)
- Third+ -F: ignored

This fix matches upstream exactly and removes oc:merge-filter from
KNOWN_FAILURES in the interop test harness.
oferchen added a commit that referenced this pull request May 1, 2026
…3084)

* fix: correct batch interop framing for read-batch and batch flags

- Add NDX-driven replay loop in replay.rs matching upstream receiver.c:
  reads NDX + iflags + sum_head + delta tokens + file checksum per file,
  with NDX_DONE phase transitions (proto >= 29 supports phase 2 redo)
- Add missing preserve_devices and preserve_acls to BatchFlags in both
  batch_support.rs (remote path) and batch.rs (local path)

* fix: reorder batch write path to produce upstream-compatible stream

Upstream rsync's batch files are a tee of the protocol stream, which
naturally has all flist entries before any per-file delta data. Our
local copy path interleaves flist entries with file data during the
directory walk, producing an incorrectly ordered batch stream.

Buffer per-file delta data (NDX + iflags + sum_head + tokens +
checksum) in an in-memory Cursor<Vec<u8>> during the walk, then
append it to the batch file after the flist end marker. This produces
the correct upstream ordering: flist entries, flist end, then
NDX-framed delta data, then NDX_DONE phase markers.

Changes:
- Add batch_delta_buf, batch_flist_index, batch_ndx_codec to CopyContext
- Add begin_batch_file_delta() for NDX + iflags + sum_head preamble
- Redirect finalize_batch_file_delta() and capture_batch_whole_file()
  to write to delta buffer instead of batch writer
- Redirect flush_literal_chunk() and copy_matched_block() token writes
  to delta buffer
- Add flush_batch_delta_to_batch() to copy buffered data and write
  NDX_DONE markers after flist finalization
- Track flist index for correct NDX numbering in delta stream

* fix: update batch replay test to use NDX-framed delta format

The test_replay_with_compression_flag test was writing raw token data
without NDX framing, but replay.rs now expects the upstream NDX-driven
format (NDX + iflags + sum_head + delta tokens + file checksum +
NDX_DONE markers).

* fix: mirror upstream rsync asymmetric negotiation precedence

Upstream compat.c:332-363 parse_negotiate_str() uses asymmetric logic:
both sides converge on the first entry in the client's list that also
appears in the server's list. The server iterates the client's (remote)
list and breaks on first match; the client iterates its own local list
and picks the first item also in the server's (remote) list.

Our implementation incorrectly iterated the remote list for both roles,
which gave server-preference ordering when acting as client. This could
select a weaker algorithm (e.g., md5) when a stronger one (e.g., xxh128)
was mutually supported and preferred by the client.

* style: fix rustfmt formatting for map_err chains

* style: use contains() instead of iter().any() per clippy

* fix: exclude zstd/lz4 from compression auto-negotiation until interop-validated

When both sides support zstd (upstream 3.4.1 built with SUPPORT_ZSTD in CI),
auto-negotiation picks zstd. However our per-token zstd read codec does not
correctly parse upstream's compressed token stream, causing "Unknown frame
descriptor" errors.

Remove zstd and lz4 from the vstring advertisement list so auto-negotiation
falls back to zlibx. Explicit --compress-choice=zstd|lz4 still works since
it bypasses vstring exchange entirely (upstream compat.c:543).

Tasks #1379 (zstd) and #1380 (lz4) track re-enabling after wire format
validation.

* fix: use NDX-framed delta format in test_replay_with_token_deltas

The test was writing raw token-format delta data after the flist end
marker, but replay() expects NDX-framed data (NDX + iflags + sum_head
+ tokens + NDX_DONE). This caused a panic on .unwrap() across all CI
platforms.

Write proper NDX framing matching upstream receiver.c:recv_files()
format: file NDX, ITEM_TRANSFER iflags, zero sum_head (whole-file
transfer), token-format literal data, and two NDX_DONE markers for
the phase 1 and phase 2 transitions.

* style: fix rustfmt for write_token_literal call

* fix: correct -FF filter shortcut tests to match upstream behavior

The integration tests in collect.rs expected 3 rules from -FF (the old
broken behavior), but upstream rsync options.c:1589-1598 produces exactly
2 rules: dir-merge /.rsync-filter (first -F) and exclude .rsync-filter
(second -F). The implementation was correct after PR #3082; only the
tests were wrong.
oferchen added a commit that referenced this pull request May 5, 2026
)

The push_rsync_filter_shortcut() function incorrectly handled the -F
flag. It added both dir-merge and exclude rules on the first -F, then
added a wrong dir-merge rule on the second -F.

Upstream rsync (options.c:1589-1598) behavior:
- First -F: `: /.rsync-filter` (dir-merge, anchored to transfer root)
- Second -F: `- .rsync-filter` (exclude filter files from transfer)
- Third+ -F: ignored

This fix matches upstream exactly and removes oc:merge-filter from
KNOWN_FAILURES in the interop test harness.
oferchen added a commit that referenced this pull request May 5, 2026
…3084)

* fix: correct batch interop framing for read-batch and batch flags

- Add NDX-driven replay loop in replay.rs matching upstream receiver.c:
  reads NDX + iflags + sum_head + delta tokens + file checksum per file,
  with NDX_DONE phase transitions (proto >= 29 supports phase 2 redo)
- Add missing preserve_devices and preserve_acls to BatchFlags in both
  batch_support.rs (remote path) and batch.rs (local path)

* fix: reorder batch write path to produce upstream-compatible stream

Upstream rsync's batch files are a tee of the protocol stream, which
naturally has all flist entries before any per-file delta data. Our
local copy path interleaves flist entries with file data during the
directory walk, producing an incorrectly ordered batch stream.

Buffer per-file delta data (NDX + iflags + sum_head + tokens +
checksum) in an in-memory Cursor<Vec<u8>> during the walk, then
append it to the batch file after the flist end marker. This produces
the correct upstream ordering: flist entries, flist end, then
NDX-framed delta data, then NDX_DONE phase markers.

Changes:
- Add batch_delta_buf, batch_flist_index, batch_ndx_codec to CopyContext
- Add begin_batch_file_delta() for NDX + iflags + sum_head preamble
- Redirect finalize_batch_file_delta() and capture_batch_whole_file()
  to write to delta buffer instead of batch writer
- Redirect flush_literal_chunk() and copy_matched_block() token writes
  to delta buffer
- Add flush_batch_delta_to_batch() to copy buffered data and write
  NDX_DONE markers after flist finalization
- Track flist index for correct NDX numbering in delta stream

* fix: update batch replay test to use NDX-framed delta format

The test_replay_with_compression_flag test was writing raw token data
without NDX framing, but replay.rs now expects the upstream NDX-driven
format (NDX + iflags + sum_head + delta tokens + file checksum +
NDX_DONE markers).

* fix: mirror upstream rsync asymmetric negotiation precedence

Upstream compat.c:332-363 parse_negotiate_str() uses asymmetric logic:
both sides converge on the first entry in the client's list that also
appears in the server's list. The server iterates the client's (remote)
list and breaks on first match; the client iterates its own local list
and picks the first item also in the server's (remote) list.

Our implementation incorrectly iterated the remote list for both roles,
which gave server-preference ordering when acting as client. This could
select a weaker algorithm (e.g., md5) when a stronger one (e.g., xxh128)
was mutually supported and preferred by the client.

* style: fix rustfmt formatting for map_err chains

* style: use contains() instead of iter().any() per clippy

* fix: exclude zstd/lz4 from compression auto-negotiation until interop-validated

When both sides support zstd (upstream 3.4.1 built with SUPPORT_ZSTD in CI),
auto-negotiation picks zstd. However our per-token zstd read codec does not
correctly parse upstream's compressed token stream, causing "Unknown frame
descriptor" errors.

Remove zstd and lz4 from the vstring advertisement list so auto-negotiation
falls back to zlibx. Explicit --compress-choice=zstd|lz4 still works since
it bypasses vstring exchange entirely (upstream compat.c:543).

Tasks #1379 (zstd) and #1380 (lz4) track re-enabling after wire format
validation.

* fix: use NDX-framed delta format in test_replay_with_token_deltas

The test was writing raw token-format delta data after the flist end
marker, but replay() expects NDX-framed data (NDX + iflags + sum_head
+ tokens + NDX_DONE). This caused a panic on .unwrap() across all CI
platforms.

Write proper NDX framing matching upstream receiver.c:recv_files()
format: file NDX, ITEM_TRANSFER iflags, zero sum_head (whole-file
transfer), token-format literal data, and two NDX_DONE markers for
the phase 1 and phase 2 transitions.

* style: fix rustfmt for write_token_literal call

* fix: correct -FF filter shortcut tests to match upstream behavior

The integration tests in collect.rs expected 3 rules from -FF (the old
broken behavior), but upstream rsync options.c:1589-1598 produces exactly
2 rules: dir-merge /.rsync-filter (first -F) and exclude .rsync-filter
(second -F). The implementation was correct after PR #3082; only the
tests were wrong.
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