diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-04-14 11:49:13 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-04-14 11:49:13 -0700 |
commit | 7a1aa0c28876e044351e78d8b8ae6cdbb10b5dfe (patch) | |
tree | 253b57c28fdea85b6e7730ab175ad89177442a0d /contrib/diff-highlight | |
parent | 3cdff83fb0519bcfed35bca987c59d3557b1f2a7 (diff) | |
parent | 8d00662d7d263448d90637ef6758fd2a0b526fec (diff) | |
download | git-7a1aa0c28876e044351e78d8b8ae6cdbb10b5dfe.tar.gz |
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
Diffstat (limited to 'contrib/diff-highlight')
-rwxr-xr-x | contrib/diff-highlight/diff-highlight | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/contrib/diff-highlight/diff-highlight b/contrib/diff-highlight/diff-highlight index 08c88bbc87..ffefc31a98 100755 --- a/contrib/diff-highlight/diff-highlight +++ b/contrib/diff-highlight/diff-highlight @@ -1,5 +1,6 @@ #!/usr/bin/perl +use 5.008; use warnings FATAL => 'all'; use strict; @@ -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 { |