Skip to content

Fix the encoding issue - 'split': invalid byte sequence in UTF-8 (Argument Error) #190

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
Show file tree
Hide file tree
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 the encoding issue - 'split': invalid byte sequence in UTF-8 (Arg…
…umentError)
  • Loading branch information
jatinganhotra committed Nov 10, 2014
commit c7fb35af1a99d6cb21656d2abc8c871aa365c51c
3 changes: 2 additions & 1 deletion lib/git/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def cache_stats
def process_full_diff
final = {}
current_file = nil
@full_diff.split("\n").each do |line|
full_diff_utf8_encoded = @full_diff.encode("UTF-8", "binary", invalid: :replace, undef: :replace)
full_diff_utf8_encoded.split("\n").each do |line|
if m = /diff --git a\/(.*?) b\/(.*?)/.match(line)
current_file = m[1]
final[current_file] = {:patch => line, :path => current_file,
Expand Down
4 changes: 3 additions & 1 deletion lib/git/lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,9 @@ def meets_required_version?
private

def command_lines(cmd, opts = [], chdir = true, redirect = '')
command(cmd, opts, chdir).split("\n")
cmd_op = command(cmd, opts, chdir)
op = cmd_op.encode("UTF-8", "binary", invalid: :replace, undef: :replace)
op.split("\n")
end

def command(cmd, opts = [], chdir = true, redirect = '', &block)
Expand Down