Skip to content

Commit 2d634db

Browse files
We cache git color stuff, so we don't need the ||= anymore
1 parent 5ad99c0 commit 2d634db

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

diff-so-fancy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ sub do_dsf_stuff {
196196
# Mercurial looks like: diff -r 82e55d328c8c hello.c
197197
if ($4 eq "-r") {
198198
$is_mercurial = 1;
199-
$meta_color ||= get_config_color("meta");
199+
$meta_color = get_config_color("meta");
200200
# Git looks like: diff --git a/diff-so-fancy b/diff-so-fancy
201201
} else {
202202
$last_file_seen = $5;
@@ -212,7 +212,7 @@ sub do_dsf_stuff {
212212
# Find the first file: --- a/README.md #
213213
########################################
214214
} elsif (!$in_hunk && $line =~ /^$ansi_color_regex--- (\w\/)?(.+?)(\e|\t|$)/) {
215-
$meta_color ||= get_config_color("meta");
215+
$meta_color = get_config_color("meta");
216216

217217
if ($git_strip_prefix) {
218218
my $file_dir = $4 || "";
@@ -364,7 +364,7 @@ sub do_dsf_stuff {
364364

365365
if ($file1 && $file2) {
366366
# We may not have extracted this yet, so we pull from the config if not
367-
$meta_color ||= get_config_color("meta");
367+
$meta_color = get_config_color("meta");
368368

369369
my $change = file_change_string($file1,$file2);
370370

test/diff-so-fancy.bats

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ output=$( load_fixture "ls-function" | $diff_so_fancy )
5353
@test "header format uses a native line-drawing character" {
5454
header=$( printf "%s" "$output" | head -n3 )
5555
run printf "%s" "$header"
56-
assert_line --index 0 --partial "[1;33m─────"
56+
assert_line --index 0 --partial "─────"
5757
assert_line --index 1 --partial "modified: fish/functions/ls.fish"
58-
assert_line --index 2 --partial "[1;33m─────"
58+
assert_line --index 2 --partial "─────"
5959
}
6060

6161
# see https://git.io/vrOF4
@@ -64,9 +64,9 @@ output=$( load_fixture "ls-function" | $diff_so_fancy )
6464
# pipe to cat(1) so we don't open stdout
6565
header=$( printf "%s" "$(load_fixture "ls-function" | $diff_so_fancy | cat)" | head -n3 )
6666
run printf "%s" "$header"
67-
assert_line --index 0 --partial "[1;33m-----"
67+
assert_line --index 0 --partial "-----"
6868
assert_line --index 1 --partial "modified: fish/functions/ls.fish"
69-
assert_line --index 2 --partial "[1;33m-----"
69+
assert_line --index 2 --partial "-----"
7070
set_env # reset env
7171
}
7272

0 commit comments

Comments
 (0)