Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/git/diff.rb')
-rw-r--r--lib/gitlab/git/diff.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/gitlab/git/diff.rb b/lib/gitlab/git/diff.rb
index a66517b4ca0..c473fe6973d 100644
--- a/lib/gitlab/git/diff.rb
+++ b/lib/gitlab/git/diff.rb
@@ -230,12 +230,16 @@ module Gitlab
private
def encode_diff_to_utf8(replace_invalid_utf8_chars)
- return unless Feature.enabled?(:convert_diff_to_utf8_with_replacement_symbol, default_enabled: :yaml)
- return unless replace_invalid_utf8_chars && !detect_binary?(@diff)
+ return unless Feature.enabled?(:convert_diff_to_utf8_with_replacement_symbol)
+ return unless replace_invalid_utf8_chars && diff_should_be_converted?
@diff = Gitlab::EncodingHelper.encode_utf8_with_replacement_character(@diff)
end
+ def diff_should_be_converted?
+ !detect_binary?(@diff) || !@diff&.valid_encoding?
+ end
+
def init_from_hash(hash)
raw_diff = hash.symbolize_keys