From 9cd565d68fbe2336eb2f488ebcef2252d2d86a3e Mon Sep 17 00:00:00 2001 From: Malo Skrylevo Date: Wed, 27 Mar 2019 16:05:08 +0300 Subject: [PATCH 1/2] Fix string with invalidly detected cp - fixes conversion from the invalid detectedfsource codepage string when used String#split method Signed-off-by: Malo Skrylevo --- lib/git/lib.rb | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/git/lib.rb b/lib/git/lib.rb index a698cf3e..2944e0ab 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -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. From 64558205829e205da1d72aff644e17922e3db506 Mon Sep 17 00:00:00 2001 From: Malo Skrylevo Date: Mon, 22 Apr 2019 19:18:08 +0300 Subject: [PATCH 2/2] process_commit_data Skip processing if message body is blank: - fixes an error when lib is trying to process message body in #process_commit_data, and throws an nil access method exception Signed-off-by: Malo Skrylevo --- lib/git/lib.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/git/lib.rb b/lib/git/lib.rb index 2944e0ab..764fd6c9 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -186,7 +186,11 @@ def process_commit_data(data, sha = nil, indent = 4) } loop do - key, *value = data.shift.split + datum = data.shift + + break if datum.nil? + + key, *value = datum.split break if key.nil?