From f437251d1bacf5c1df81e018e54d5b238cb97b4d Mon Sep 17 00:00:00 2001 From: taicsuzu Date: Mon, 11 Jun 2018 17:33:51 +0900 Subject: [PATCH] do not force to encode --- lib/git/diff.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/git/diff.rb b/lib/git/diff.rb index 19da0e92..ff819be0 100644 --- a/lib/git/diff.rb +++ b/lib/git/diff.rb @@ -127,10 +127,11 @@ def process_full_diff } final = {} current_file = nil - full_diff_utf8_encoded = @full_diff.encode("UTF-8", "binary", { - :invalid => :replace, - :undef => :replace - }) + if @full_diff.encoding.name != "UTF-8" + full_diff_utf8_encoded = @full_diff.encode("UTF-8", "binary", { :invalid => :replace, :undef => :replace }) + else + full_diff_utf8_encoded = @full_diff + end full_diff_utf8_encoded.split("\n").each do |line| if m = /^diff --git a\/(.*?) b\/(.*?)/.match(line) current_file = m[1]