Skip to content

fix: properly parse UTF-8(multibyte) file paths in git output #839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 20, 2025

Conversation

kaorukobo
Copy link
Contributor

Description of Bug

The current implementation cannot correctly retrieve the status of file paths containing multibyte characters such as UTF-8. Here's how to reproduce the issue:

docker run -it --rm ruby:3.4-bullseye bash

gem install -N git:4.0.4

cd /tmp
git init
touch 👍️
git add 👍️
ruby -rgit -e 'p Git.open(".").status.first.path'
# => "\"\\360\\237\\221\\215\\357\\270\\217\""
#     ^^😱

The path contains a quoted string. The current git/lib.rb has the unescape_quoted_path method, and some processes use this method. But it's not used consistently across all file status retrieval operations.

Fix

I added tests for file paths containing multibyte characters to test_status.rb and modified various parts of git/lib.rb to use the unescape_quoted_path method so that these tests pass.

Since this change exceeds the maximum class line count defined in .rubocop_todo.yml, I've increased the limit. I believe the complicated lib.rb will naturally improve through the ongoing architectural redesign.

Copy link
Member

@jcouball jcouball left a comment

Choose a reason for hiding this comment

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

Great fix and nice test. Thank you, @kaorukobo

@jcouball jcouball merged commit 4430478 into ruby-git:main Aug 20, 2025
7 checks passed
@jcouball
Copy link
Member

This fix has been deployed to rubygems.org in git-4.0.5

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.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy