Skip to content

Fix string with wrongly detected cp #410

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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix string with invalidly detected cp
- fixes conversion from the invalid detectedfsource codepage string when
  used String#split method

Signed-off-by: Malo Skrylevo <majioa@yandex.ru>
  • Loading branch information
majioa committed Mar 27, 2019
commit 9cd565d68fbe2336eb2f488ebcef2252d2d86a3e
20 changes: 15 additions & 5 deletions lib/git/lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -902,14 +902,24 @@ def meets_required_version?
def command_lines(cmd, opts = [], chdir = true, redirect = '')
cmd_op = command(cmd, opts, chdir)
if cmd_op.encoding.name != "UTF-8"
op = cmd_op.encode("UTF-8", "binary", {
:invalid => :replace,
:undef => :replace
})
op = command_line_convert(cmd_op)
else
op = cmd_op
end
op.split("\n")

begin
op.split("\n")
rescue ArgumentError
op = command_line_convert(cmd_op)
retry
end
end

def command_line_convert(cmd_op)
cmd_op.encode("UTF-8", "binary", {
:invalid => :replace,
:undef => :replace
})
end

# Takes the current git's system ENV variables and store them.
Expand Down