Skip to content

Commit

Permalink
Merge branch 'jk/colors' into maint
Browse files Browse the repository at this point in the history
"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
  • Loading branch information
Junio C Hamano committed Apr 21, 2015
2 parents d3115a3 + 8d00662 commit d544696
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions contrib/diff-highlight/diff-highlight
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/perl

use 5.008;
use warnings FATAL => 'all';
use strict;

Expand Down Expand Up @@ -164,8 +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 {
Expand Down

0 comments on commit d544696

Please sign in to comment.