Merge branch 'jk/colors' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 21 Apr 2015 19:12:25 +0000 (12:12 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 21 Apr 2015 19:12:25 +0000 (12:12 -0700)
"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

1  2 
contrib/diff-highlight/diff-highlight
index 08c88bbc87e51e25cacc5826b26a223f3bfbd382,54b359b7b77b4eb29efc64632b789a3c607c63b6..ffefc31a98a26dfd65d188bbb547cc114231c13d
@@@ -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 {