Skip to content

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