Skip to content

Commit 5c96bdd

Browse files
Colorize file add/deletes (#253)
1 parent 790afa7 commit 5c96bdd

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

diff-so-fancy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,10 +545,12 @@ sub file_change_string {
545545
return "modified: $file_1";
546546
# If the first is /dev/null it's a new file
547547
} elsif ($file_1 eq "/dev/null") {
548-
return "added: $file_2";
548+
my $add_color = $DiffHighlight::NEW_HIGHLIGHT[1];
549+
return "added: $add_color$file_2$reset_color";
549550
# If the second is /dev/null it's a deletion
550551
} elsif ($file_2 eq "/dev/null") {
551-
return "deleted: $file_1";
552+
my $del_color = $DiffHighlight::OLD_HIGHLIGHT[1];
553+
return "deleted: $del_color$file_1$reset_color";
552554
# If the files aren't the same it's a rename
553555
} elsif ($file_1 ne $file_2) {
554556
my ($old, $new) = DiffHighlight::highlight_pair($file_1,$file_2,{only_diff => 1});

lib/DiffHighlight.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ use Encode;
77

88
# Highlight by reversing foreground and background. You could do
99
# other things like bold or underline if you prefer.
10-
my @OLD_HIGHLIGHT = (
10+
our @OLD_HIGHLIGHT = (
1111
color_config('color.diff-highlight.oldnormal'),
1212
color_config('color.diff-highlight.oldhighlight', "\x1b[7m"),
1313
"\x1b[27m",
1414
);
15-
my @NEW_HIGHLIGHT = (
15+
our@NEW_HIGHLIGHT = (
1616
color_config('color.diff-highlight.newnormal', $OLD_HIGHLIGHT[0]),
1717
color_config('color.diff-highlight.newhighlight', $OLD_HIGHLIGHT[1]),
1818
$OLD_HIGHLIGHT[2],

0 commit comments

Comments
 (0)