Skip to content

Commit fe680f8

Browse files
drakmailperlun
authored andcommitted
Fix UTF-8 message errors (ruby-git#327)
1 parent 667de5a commit fe680f8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/git/lib.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -860,10 +860,14 @@ def meets_required_version?
860860

861861
def command_lines(cmd, opts = [], chdir = true, redirect = '')
862862
cmd_op = command(cmd, opts, chdir)
863-
op = cmd_op.encode("UTF-8", "binary", {
864-
:invalid => :replace,
865-
:undef => :replace
866-
})
863+
if cmd_op.encoding.name != "UTF-8"
864+
op = cmd_op.encode("UTF-8", "binary", {
865+
:invalid => :replace,
866+
:undef => :replace
867+
})
868+
else
869+
op = cmd_op
870+
end
867871
op.split("\n")
868872
end
869873

0 commit comments

Comments
 (0)