File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55diff_highlight=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) /third_party/diff-highlight/diff-highlight"
66
7+ hash gsed 2> /dev/null && SED=gsed || SED=sed
8+
79color_code_regex=$' (\x1B \\ [([0-9]{1,2}(;[0-9]{1,2})?)[m|K])?'
810reset_color=" \x1B\[m"
911dim_magenta=" \x1B\[38;05;146m"
1012
1113format_diff_header () {
1214 # simplify the unified patch diff header
13- sed -E " s/^($color_code_regex )diff --git .*$//g" | \
14- sed -E " s/^($color_code_regex )index .*$/\
15+ $SED -E " s/^($color_code_regex )diff --git .*$//g" | \
16+ $SED -E " s/^($color_code_regex )index .*$/\
1517\1$( print_horizontal_rule) /g" | \
16- sed -E " s/^($color_code_regex )\+\+\+(.*)$/\1\+\+\+\5\\
18+ $SED -E " s/^($color_code_regex )\+\+\+(.*)$/\1\+\+\+\5\\
1719\1$( print_horizontal_rule) /g"
1820}
1921
2022colorize_context_line () {
2123 # extra color for @@ context line
22- sed -E " s/@@$reset_color $reset_color (.*$)/@@ $dim_magenta \1/g"
24+ $SED -E " s/@@$reset_color $reset_color (.*$)/@@ $dim_magenta \1/g"
2325}
2426
2527strip_leading_symbols () {
2628 # strip the + and -
27- sed -E " s/^($color_code_regex )[\+\-]/\1 /g"
29+ $SED -E " s/^($color_code_regex )[\+\-]/\1 /g"
2830}
2931
3032print_horizontal_rule () {
31- printf " %$( tput cols) s\n" | sed ' s/ /─/g'
33+ printf " %$( tput cols) s\n" | $SED ' s/ /─/g'
3234}
3335
3436# run it.
You can’t perform that action at this time.
0 commit comments