Detect and reproduce external-compression level - #296
Merged
Conversation
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>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
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.