Skip to content

Detect and reproduce external-compression level - #296

Merged
jmacd merged 3 commits into
mainfrom
jmacd/comp-level
Jun 21, 2026
Merged

Detect and reproduce external-compression level#296
jmacd merged 3 commits into
mainfrom
jmacd/comp-level

Conversation

@jmacd

@jmacd jmacd commented Jun 21, 2026

Copy link
Copy Markdown
Owner

When xdelta3 auto-decompresses an externally compressed input (bzip2, gzip, xz) and later auto-recompresses the decoded output, reproduce the original compression level so the recompressed bytes match the original.

The level is detected from the stream header at encode time (bzip2 exact, gzip/xz best-effort), carried in the VCDIFF application header as "" (e.g. "B9"), parsed back out on decode, and passed as "-N" to the recompressor. gzip also gains "-n" so its header is reproducible.

-G emits a legacy app-header (bare "") for compatibility with older xdelta3 versions, which exact-match the compressor ident and would otherwise decline to recompress a new delta's output. Old deltas (no level digit) decode unchanged.

Adds testing/recompress_level_test.sh, a deterministic bzip2 round-trip regression test (registered as a CTest), covering byte-identical recompression at levels 1/5/9 and the -G legacy path.

When xdelta3 auto-decompresses an externally compressed input (bzip2,
gzip, xz) and later auto-recompresses the decoded output, reproduce the
original compression level so the recompressed bytes match the original.

The level is detected from the stream header at encode time (bzip2 exact,
gzip/xz best-effort), carried in the VCDIFF application header as
"<ident><level>" (e.g. "B9"), parsed back out on decode, and passed as
"-N" to the recompressor.  gzip also gains "-n" so its header is
reproducible.

-G emits a legacy app-header (bare "<ident>") for compatibility with
older xdelta3 versions, which exact-match the compressor ident and would
otherwise decline to recompress a new delta's output.  Old deltas (no
level digit) decode unchanged.

Adds testing/recompress_level_test.sh, a deterministic bzip2 round-trip
regression test (registered as a CTest), covering byte-identical
recompression at levels 1/5/9 and the -G legacy path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jmacd jmacd mentioned this pull request Jun 21, 2026
jmacd and others added 2 commits June 20, 2026 21:01
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jmacd
jmacd merged commit d322d0a into main Jun 21, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant