Skip to content

Commit e5bddde

Browse files
Merge branch 'master' of github.com:so-fancy/diff-so-fancy
2 parents 93f360b + f222ff7 commit e5bddde

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

diff-so-fancy

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,10 @@ sub do_dsf_stuff {
345345
}
346346

347347
my $next = shift(@$input);
348-
my ($file1) = $next =~ /rename from (.+)/;
348+
my ($file1) = $next =~ /rename from (.+?)(\e|\t|$)/;
349349

350350
$next = shift(@$input);
351-
my ($file2) = $next =~ /rename to (.+)/;
351+
my ($file2) = $next =~ /rename to (.+?)(\e|\t|$)/;
352352

353353
if ($file1 && $file2) {
354354
# We may not have extracted this yet, so we pull from the config if not
@@ -663,14 +663,10 @@ sub file_change_string {
663663
# If the files aren't the same it's a rename
664664
} elsif ($file_1 ne $file_2) {
665665
my ($old, $new) = DiffHighlight::highlight_pair($file_1,$file_2,{only_diff => 1});
666+
# highlight_pair already includes reset_color, but adds newline characters that need to be trimmed off
666667
$old = trim($old);
667668
$new = trim($new);
668-
669-
# highlight_pair resets the colors, but we want it to be the meta color
670-
$old =~ s/(\e0?\[m)/$1$meta_color/g;
671-
$new =~ s/(\e0?\[m)/$1$meta_color/g;
672-
673-
return "renamed: $old to $new";
669+
return "renamed: $old$meta_color to $new"
674670
# Something we haven't thought of yet
675671
} else {
676672
return "$file_1 -> $file_2";

pro-tips.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
#### One-off fanciness or a specific diff-so-fancy alias
44

5-
You can do also do a one-off or a specific `diff-so-fancy` alias:
5+
You can do also do a one-off:
66
```shell
77
git diff --color | diff-so-fancy
8-
9-
git config --global alias.dsf '!f() { [ -z "$GIT_PREFIX" ] || cd "$GIT_PREFIX" '\
10-
'&& git diff --color "$@" | diff-so-fancy | less --tabs=4 -RFXS; }; f'
8+
```
9+
or configure an alias and a corresponding pager to use `diff-so-fancy`:
10+
```shell
11+
git config --global alias.dsf "diff --color"
12+
git config --global pager.dsf "diff-so-fancy | less --tabs=4 -RFXS"
1113
```
1214

1315
#### Opting-out

0 commit comments

Comments
 (0)