Repository navigation
fix(log): preserve line endings from files and stdin - #5381
Open
zhiwuyazhe-fjr wants to merge 1 commit into
Open
zhiwuyazhe-fjr wants to merge 1 commit into
zhiwuyazhe-fjr wants to merge 1 commit into
Conversation
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.
Fixes #5380.
A two-line CRLF log produced different bytes depending on how it reached
rtk log. The file path appended a blank line, and the stdin path also replaced both CRLF endings with LF. Even empty input produced one byte of output.Read the stdin text without rebuilding its lines and use the existing
emit_guardedprinter for both entry points. It preserves existing line endings, supplies one newline to nonempty unterminated text, and returns the exact output for savings tracking.Verification
one\ntwo\n\nthrough stdin. The patched binary returnsone\r\ntwo\r\nthrough both entry points. An empty log now emits zero bytes.cargo fmt --all --check,cargo clippy --all-targets -- -D warningsandcargo test --allon Linux (6,057 tests passed, 8 ignored).