From: Junio C Hamano Date: Tue, 14 Apr 2015 18:49:13 +0000 (-0700) Subject: Merge branch 'jk/colors' X-Git-Tag: v2.4.0-rc2~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/7a1aa0c28876e044351e78d8b8ae6cdbb10b5dfe?ds=inline;hp=-c Merge branch 'jk/colors' "diff-highlight" (in contrib/) used to show byte-by-byte differences, which meant that multi-byte characters can be chopped in the middle. It learned to pay attention to character boundaries (assuming the UTF-8 payload). * jk/colors: diff-highlight: do not split multibyte characters --- 7a1aa0c28876e044351e78d8b8ae6cdbb10b5dfe diff --combined contrib/diff-highlight/diff-highlight index 08c88bbc87,54b359b7b7..ffefc31a98 --- a/contrib/diff-highlight/diff-highlight +++ b/contrib/diff-highlight/diff-highlight @@@ -1,5 -1,6 +1,6 @@@ #!/usr/bin/perl + use 5.008; use warnings FATAL => 'all'; use strict; @@@ -24,10 -25,6 +25,10 @@@ my @removed my @added; my $in_hunk; +# Some scripts may not realize that SIGPIPE is being ignored when launching the +# pager--for instance scripts written in Python. +$SIG{PIPE} = 'DEFAULT'; + while (<>) { if (!$in_hunk) { print; @@@ -164,8 -161,12 +165,12 @@@ sub highlight_pair sub split_line { local $_ = shift; - return map { /$COLOR/ ? $_ : (split //) } - split /($COLOR*)/; + return utf8::decode($_) ? + map { utf8::encode($_); $_ } + map { /$COLOR/ ? $_ : (split //) } + split /($COLOR+)/ : + map { /$COLOR/ ? $_ : (split //) } + split /($COLOR+)/; } sub highlight_line {