rugged icon indicating copy to clipboard operation
rugged copied to clipboard

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

Open HM2468 opened this issue 4 years ago • 1 comments

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 avatar Aug 22 '21 08:08 HM2468

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?

carlosmn avatar Aug 26 '21 09:08 carlosmn