Skip to content

Add mtree CRLF/content compatibility normalization#2709

Merged
ChanTsune merged 1 commit into
mainfrom
codex/mtree-crlf-compat-layer
Feb 11, 2026
Merged

Add mtree CRLF/content compatibility normalization#2709
ChanTsune merged 1 commit into
mainfrom
codex/mtree-crlf-compat-layer

Conversation

@ChanTsune
Copy link
Copy Markdown
Owner

@ChanTsune ChanTsune commented Feb 8, 2026

Summary by CodeRabbit

  • New Features

    • Added support for the content= keyword alias in mtree manifests for improved compatibility.
  • Bug Fixes

    • Improved mtree parsing to correctly handle CRLF and CR line endings from files created on different systems.
  • Tests

    • Added test coverage for mtree files using CRLF line endings and wrapped content lines.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 8, 2026

Warning

Rate limit exceeded

@ChanTsune has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 36 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

The pull request introduces normalization of mtree input to handle cross-platform line endings (CRLF/CR to LF conversion) and rewrite the content= keyword alias to the libarchive-standard contents= format. It adds helper functions for normalization and updates the mtree parser to consume normalized input, with corresponding integration test coverage.

Changes

Cohort / File(s) Summary
mtree Input Normalization
cli/src/command/core/mtree.rs
Adds normalization logic to convert line endings and rewrite content= keyword alias to contents= before parsing. Introduces helper functions: normalize_mtree_input, normalize_line_endings, rewrite_content_keyword_alias, rewrite_content_keyword_line, and is_mtree_whitespace. Updates transform_mtree_entries to consume normalized input via Cursor. Includes tests for line ending conversion and keyword rewriting.
mtree Integration Test
cli/tests/cli/stdio/mtree.rs
Adds stdio_mtree_crlf_wrapped_and_content_alias integration test validating mtree parsing with CRLF line endings, wrapped lines, and content= alias syntax. Test creates manifest, builds archive, extracts, and verifies resulting file contents.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • #2644: Directly modifies mtree parsing in cli/src/command/core/mtree.rs with related handling of mtree transform_mtree_entries functionality.

Suggested labels

cli

Poem

🐰 With CRLF cast aside and endings made pure,
Content becomes Contents—the parsing's more sure.
Line wraps and aliases now play along,
A normalized journey where all bytes belong! 📜✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main changes: adding normalization for mtree CRLF line endings and content= keyword alias support, which are the primary focuses of the implementation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/mtree-crlf-compat-layer

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @ChanTsune, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the robustness of mtree parsing within the pna command-line interface. By introducing a normalization layer, the system can now correctly interpret mtree manifests that use different line ending conventions (CRLF/CR) or keyword aliases (content= instead of contents=). This ensures that pna can seamlessly process mtree files generated by a wider range of tools, preventing parsing errors and enhancing the reliability of archive operations.

Highlights

  • Mtree Input Normalization: Introduced a new preprocessing step for mtree input to enhance compatibility with various sources, including bsdtar.
  • Line Ending Conversion: Implemented logic to convert CRLF and CR line endings to LF, ensuring consistent parsing of mtree manifests.
  • Keyword Aliasing: Added functionality to rewrite the content= keyword to contents= for compatibility with libarchive's mtree format.
  • Comprehensive Testing: Included new unit tests for the normalization functions and an integration test to validate end-to-end compatibility with complex mtree manifests.
Changelog
  • cli/src/command/core/mtree.rs
    • Added normalize_mtree_input function to preprocess mtree data before parsing.
    • Implemented normalize_line_endings to convert CRLF/CR to LF.
    • Developed rewrite_content_keyword_alias to transform content= to contents= keywords.
    • Integrated the normalization step into the transform_mtree_entries function.
    • Added new unit tests for the normalization logic, covering line endings, keyword aliasing, and edge cases like wrapped lines.
  • cli/tests/cli/stdio/mtree.rs
    • Added a new integration test stdio_mtree_crlf_wrapped_and_content_alias to verify the end-to-end functionality of mtree input normalization, including CRLF, wrapped lines, and content= keyword handling during archive creation and extraction.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces normalization for mtree input to improve compatibility, specifically handling CRLF/CR line endings and aliasing content= to contents=. The changes are logical and include new unit and integration tests. However, I've identified a bug in the parsing logic that incorrectly handles filenames with escaped whitespace, which could lead to manifest corruption. I've also suggested a performance improvement to the normalization process by combining multiple steps into a single pass to reduce memory allocations and processing time. Finally, I've recommended adding a test case to cover filenames with escaped characters to prevent future regressions.

Comment thread cli/src/command/core/mtree.rs
Comment thread cli/src/command/core/mtree.rs Outdated
Comment thread cli/src/command/core/mtree.rs
@github-actions github-actions Bot added the cli This issue is about cli application label Feb 8, 2026
@ChanTsune ChanTsune force-pushed the codex/mtree-crlf-compat-layer branch from 68ba664 to e5b34d1 Compare February 8, 2026 08:47
Normalize mtree input before parsing with mtree2 to handle
bsdtar-style manifests that use CRLF line endings or the
non-standard `content=` keyword shorthand.
@ChanTsune ChanTsune force-pushed the codex/mtree-crlf-compat-layer branch from e5b34d1 to 2202249 Compare February 8, 2026 08:59
@ChanTsune ChanTsune merged commit 7897f58 into main Feb 11, 2026
104 of 105 checks passed
@ChanTsune ChanTsune deleted the codex/mtree-crlf-compat-layer branch February 11, 2026 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli This issue is about cli application

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant