libgit2 / libgit2/rugged

Rugged::Diff::Delta #new_file / #old_file method got a wrong encoded [:path] string

Open
#888 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
2.3k
Forks
293
PR merge metrics
No merged PRs in 30d

Description

when I call new_file[:path] / old_file[:path] of Rugged::Diff::Delta, I got result as follow:

  [{:path=>"test/.keep", :type=>"added"},
   {:path=>"test/\xE4\xB8\xAD\xE6\x96\x87\xE5\x90\x8D\xE6\xB5\x8B\xE8\xAF\x95\xE4\xB8\x80.txt", :type=>"added"},
   {:path=>"test/\xE4\xB8\xAD\xE6\x96\x87\xE5\x90\x8D\xE6\xB5\x8B\xE8\xAF\x95\xE4\xB8\x89.txt", :type=>"added"},
   {:path=>"test/\xE4\xB8\xAD\xE6\x96\x87\xE5\x90\x8D\xE6\xB5\x8B\xE8\xAF\x95\xE4\xBA\x8C.txt", :type=>"added"},
   {:path=>"\xE4\xB8\xAD\xE6\x96\x87.  \xE5\x91\xBD\xE5\x90\x8D1.txt", :type=>"added"}]}

when I copy the path value to my console pry/irb, I got the right string

It seems to be an incorrectly decoded problem

[66] pry(main)> "test/\xE4\xB8\xAD\xE6\x96\x87\xE5\x90\x8D\xE6\xB5\x8B\xE8\xAF\x95\xE4\xB8\x80.txt"
=> "test/中文名测试一.txt"
[67] pry(main)> "test/\xE4\xB8\xAD\xE6\x96\x87\xE5\x90\x8D\xE6\xB5\x8B\xE8\xAF\x95\xE4\xB8\x89.txt"
=> "test/中文名测试三.txt"
[68] pry(main)> "test/\xE4\xB8\xAD\xE6\x96\x87\xE5\x90\x8D\xE6\xB5\x8B\xE8\xAF\x95\xE4\xBA\x8C.txt"
=> "test/中文名测试二.txt"

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue through Rugged::Diff::Delta#new_file and #old_file using the non-ASCII paths shown. Trace how path strings are encoded in the Rugged Ruby bindings and libgit2 boundary; done means these entry points return the expected Unicode paths and a regression test covers them.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, git, ruby
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.