Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
123 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env ruby | ||
# encoding: utf-8 | ||
|
||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
# Test diff when the file path has to be quoted according to core.quotePath | ||
# See https://git-scm.com/docs/git-config#Documentation/git-config.txt-corequotePath | ||
# | ||
class TestDiffWithEscapedPath < Test::Unit::TestCase | ||
def test_diff_with_non_ascii_filename | ||
in_temp_dir do |path| | ||
create_file('my_other_file_☠', "First Line\n") | ||
`git init` | ||
`git add .` | ||
`git config --local core.safecrlf false` if Gem.win_platform? | ||
`git commit -m "First Commit"` | ||
update_file('my_other_file_☠', "Second Line\n") | ||
diff_paths = Git.open('.').diff.map(&:path) | ||
assert_equal(["my_other_file_☠"], diff_paths) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env ruby | ||
# encoding: utf-8 | ||
|
||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
# Test diff when the file path has to be quoted according to core.quotePath | ||
# See https://git-scm.com/docs/git-config#Documentation/git-config.txt-corequotePath | ||
# See https://www.jvt.me/posts/2020/06/23/byte-array-to-string-ruby/ | ||
# | ||
class TestUnescapePath < Test::Unit::TestCase | ||
def test_simple_path | ||
path = 'my_other_file' | ||
expected_unescaped_path = 'my_other_file' | ||
assert_equal(expected_unescaped_path, Git::Lib.unescape_path(path)) | ||
end | ||
|
||
def test_unicode_path | ||
path = 'my_other_file_\\342\\230\\240' | ||
expected_unescaped_path = 'my_other_file_☠' | ||
assert_equal(expected_unescaped_path, Git::Lib.unescape_path(path)) | ||
end | ||
|
||
def test_single_char_escapes | ||
Git::Lib::UNESCAPES.each_pair do |escape_char, expected_char| | ||
path = "\\#{escape_char}" | ||
assert_equal(expected_char.chr, Git::Lib.unescape_path(path)) | ||
end | ||
end | ||
|
||
def test_compound_escape | ||
path = "my_other_file_\\\"\\342\\230\\240\\n\\\"" | ||
expected_unescaped_path = 'my_other_file_"☠' + "\n" + '"' | ||
assert_equal(expected_unescaped_path, Git::Lib.unescape_path(path)) | ||
end | ||
end |