diff options
| author | Junio C Hamano <gitster@pobox.com> | 2026-03-27 11:00:00 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-03-27 11:00:00 -0700 |
| commit | ebd8fa7e1291e4f82992db763e271ca261dd750b (patch) | |
| tree | 527a5d23d7b5777b8978cf25004a5991b81c0881 /contrib/diff-highlight/DiffHighlight.pm | |
| parent | 41688c1a2312f62f44435e1a6d03b4b904b5b0ec (diff) | |
| parent | 598f40c4b3de30d8f7c0666823a9d90884b78bee (diff) | |
| download | git-ebd8fa7e1291e4f82992db763e271ca261dd750b.tar.xz | |
Merge branch 'jk/diff-highlight-identical-pairs'
The handling of the incomplete lines at the end by "git
diff-highlight" has been fixed.
* jk/diff-highlight-identical-pairs:
contrib/diff-highlight: do not highlight identical pairs
Diffstat (limited to 'contrib/diff-highlight/DiffHighlight.pm')
| -rw-r--r-- | contrib/diff-highlight/DiffHighlight.pm | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/contrib/diff-highlight/DiffHighlight.pm b/contrib/diff-highlight/DiffHighlight.pm index 3d061bc0b7..f0607a4b68 100644 --- a/contrib/diff-highlight/DiffHighlight.pm +++ b/contrib/diff-highlight/DiffHighlight.pm @@ -273,6 +273,18 @@ sub highlight_line { # or suffix (disregarding boring bits like whitespace and colorization). sub is_pair_interesting { my ($a, $pa, $sa, $b, $pb, $sb) = @_; + + # We hit this case if the prefix consumed the entire line, meaning + # that two lines are identical. This generally shouldn't happen, + # since it implies the diff isn't minimal (you could shrink the hunk by + # making this a context line). But you can see it when the line + # content is the same, but the trailing newline is dropped, like: + # + # -foo + # +foo + # \No newline at end of file + return 0 if $pa == @$a || $pb == @$b; + my $prefix_a = join('', @$a[0..($pa-1)]); my $prefix_b = join('', @$b[0..($pb-1)]); my $suffix_a = join('', @$a[($sa+1)..$#$a]); |
