Skip to content

Fix/windows path prefix stripping#2833

Merged
ChanTsune merged 1 commit into
mainfrom
fix/windows-path-prefix-stripping
Mar 20, 2026
Merged

Fix/windows path prefix stripping#2833
ChanTsune merged 1 commit into
mainfrom
fix/windows-path-prefix-stripping

Conversation

@ChanTsune

@ChanTsune ChanTsune commented Mar 20, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced Windows command-line argument handling to properly process paths without unwanted conversion.
  • Tests

    • Added Windows path normalization validation tests for CLI commands.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 enhances the application's compatibility with Windows environments by addressing how paths are handled, particularly when interacting with tools like bsdtar through MSYS2. It ensures that path arguments are correctly interpreted without unintended conversions and that the internal PathnameEditor can robustly process and normalize various Windows path formats, leading to more reliable operation on Windows.

Highlights

  • MSYS2 Path Conversion Fix: Introduced environment variables in the pnatar-wrapper.sh script to prevent MSYS2 from incorrectly converting POSIX-style paths to Windows paths, which was breaking bsdtar tests.
  • Windows Path Handling Tests: Added a comprehensive suite of Windows-specific unit tests to cli/src/command/core/path.rs to validate that the PathnameEditor correctly strips various Windows path prefixes (e.g., drive letters, device paths) and normalizes path separators to forward slashes, mirroring bsdtar's behavior.
  • Minor Output Formatting Adjustment: Adjusted the output mechanism in cli/src/command/list.rs for bsd_tar_list_entries_to to ensure consistent newline handling.
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.

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.

@coderabbitai

coderabbitai Bot commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ce5f18da-d37c-4cef-a2e6-56a444edc5a0

📥 Commits

Reviewing files that changed from the base of the PR and between 3ad4b12 and 2d0bed7.

📒 Files selected for processing (2)
  • .github/scripts/pnatar-wrapper.sh
  • cli/src/command/core/path.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/scripts/pnatar-wrapper.sh
  • cli/src/command/core/path.rs

📝 Walkthrough

Walkthrough

The changes address Windows path handling by disabling MSYS2's automatic path conversion in the wrapper script and adding comprehensive Windows-specific unit tests for path entry name normalization in the CLI.

Changes

Cohort / File(s) Summary
MSYS2 Wrapper Configuration
.github/scripts/pnatar-wrapper.sh
Exports MSYS_NO_PATHCONV=1 and MSYS2_ARG_CONV_EXCL='*' before invoking pna.exe to disable MSYS2's automatic POSIX-to-Windows path conversion and argument handling.
Windows Path Normalization Tests
cli/src/command/core/path.rs
Adds #[cfg(windows)] unit tests for PathnameEditor::edit_entry_name() validating stripping of Windows-specific path prefixes (drive letters, device prefixes like \\\\.\\, verbatim prefixes like \\?\) and normalization of backslashes to forward slashes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A wrapper hops through Windows paths so fine,
With MSYS2 tamed, the slashes align,
Tests verify each prefix stripped with care,
Backslashes converted, forward paths fair!

🚥 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 title accurately reflects the main changes: Windows path prefix stripping in path.rs and MSYS2 path conversion handling in the wrapper script.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/windows-path-prefix-stripping
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@github-actions github-actions Bot added the cli This issue is about cli application label Mar 20, 2026

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

Copy link
Copy Markdown
Contributor

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 addresses an issue with Windows path prefix stripping by setting appropriate MSYS2 environment variables in the wrapper script. It also introduces a comprehensive suite of tests to validate various Windows path formats. My review focuses on improving the maintainability of the new test code and simplifying a formatting change.

Comment thread cli/src/command/core/path.rs
Comment thread cli/src/command/list.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
cli/src/command/list.rs (1)

828-832: Prefer a single writeln! call for one logical record.

At Line 828 and Line 832, this now emits each row via two writes. It works, but one writeln! is a bit cleaner and reduces partial-write risk between content and newline.

Suggested simplification
-        write!(
-            out,
-            "{perm} {nlink} {uname:<u_width$} {gname}{size_str:>size_width$} {mtime} {name}"
-        )?;
-        writeln!(out)?;
+        writeln!(
+            out,
+            "{perm} {nlink} {uname:<u_width$} {gname}{size_str:>size_width$} {mtime} {name}"
+        )?;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cli/src/command/list.rs` around lines 828 - 832, Combine the two separate
writes into a single logical write: replace the pair of write!(out, "{perm}
{nlink} {uname:<u_width$} {gname}{size_str:>size_width$} {mtime} {name}")?;
writeln!(out)?; with one writeln!(...) call that emits the same formatted row
and newline in one shot, referencing the same variables (out, perm, nlink,
uname, u_width, gname, size_str, size_width, mtime, name) so the output for each
record is atomic and avoids partial-write risk.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@cli/src/command/list.rs`:
- Around line 828-832: Combine the two separate writes into a single logical
write: replace the pair of write!(out, "{perm} {nlink} {uname:<u_width$}
{gname}{size_str:>size_width$} {mtime} {name}")?; writeln!(out)?; with one
writeln!(...) call that emits the same formatted row and newline in one shot,
referencing the same variables (out, perm, nlink, uname, u_width, gname,
size_str, size_width, mtime, name) so the output for each record is atomic and
avoids partial-write risk.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8fcf0b59-334a-46eb-9e15-ff9ba33bac69

📥 Commits

Reviewing files that changed from the base of the PR and between d41b42f and 3ad4b12.

📒 Files selected for processing (3)
  • .github/scripts/pnatar-wrapper.sh
  • cli/src/command/core/path.rs
  • cli/src/command/list.rs

Disable MSYS2 automatic path conversion in the pnatar wrapper to
prevent mangling of Windows absolute paths (\\?\, \\.\, drive letters)
passed by bsdtar's test_windows. Add cfg(windows) tests covering
all 8 path prefix types from test_windows.c.
@ChanTsune
ChanTsune force-pushed the fix/windows-path-prefix-stripping branch from af3d1ea to 2d0bed7 Compare March 20, 2026 03:36
@ChanTsune
ChanTsune merged commit c22b392 into main Mar 20, 2026
110 of 111 checks passed
@ChanTsune
ChanTsune deleted the fix/windows-path-prefix-stripping branch March 20, 2026 13:11
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