Skip to content
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

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

Open
HM2468 opened this issue Aug 22, 2021 · 1 comment

Comments

@HM2468
Copy link

HM2468 commented Aug 22, 2021

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"
@HM2468 HM2468 changed the title Rugged::Patch new_file[:path] / old_file[:path] got wrong encoded string Rugged::Patch #new_file / #old_file method got a wrong encoded [:path] string Aug 22, 2021
@HM2468 HM2468 changed the title Rugged::Patch #new_file / #old_file method got a wrong encoded [:path] string Rugged::Diff::Delta #new_file / #old_file method got a wrong encoded [:path] string Aug 22, 2021
@carlosmn
Copy link
Member

The escape codes seem to be what you should be expecting. Git paths are arbitrary binary bytestrings so it looks like whatever you're using to print out the structure is erring on the side of caution and showing anything non-ascii like that.

Does it still happen if you tag the strings with whatever the right encoding is for your repository?

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

No branches or pull requests

2 participants