@@ -849,41 +849,39 @@ sub color {
849849}
850850
851851# Get colors used for various output sections (memoized)
852- {
853- my $static_config ;
852+ sub get_config_color {
853+ my $str = shift () ;
854854
855- sub get_config_color {
856- my $str = shift ();
855+ state $static_config ;
857856
858- my $ret = " " ;
859- if ($static_config -> {$str }) {
860- return $static_config -> {$str };
861- }
857+ my $ret = " " ;
858+ if ($static_config -> {$str }) {
859+ return $static_config -> {$str };
860+ }
862861
863- # print color(15) . "Shelling out for color: '$str'\n" . color('reset');
864-
865- if ($str eq " meta" ) {
866- # Default ANSI yellow
867- $ret = git_ansi_color(git_config(' color.diff.meta' )) || color(11);
868- } elsif ($str eq " reset" ) {
869- $ret = color(" reset" );
870- } elsif ($str eq " add_line" ) {
871- # Default ANSI green
872- $ret = git_ansi_color(git_config(' color.diff.new' )) || color(" 2_bold" );
873- } elsif ($str eq " remove_line" ) {
874- # Default ANSI red
875- $ret = git_ansi_color(git_config(' color.diff.old' )) || color(" 1_bold" );
876- } elsif ($str eq " fragment" ) {
877- $ret = git_ansi_color(git_config(' color.diff.frag' )) || color(" 13_bold" );
878- } elsif ($str eq " last_function" ) {
879- $ret = git_ansi_color(git_config(' color.diff.func' )) || color(" 146_bold" );
880- }
862+ # print color(15) . "Shelling out for color: '$str'\n" . color('reset');
863+
864+ if ($str eq " meta" ) {
865+ # Default ANSI yellow
866+ $ret = git_ansi_color(git_config(' color.diff.meta' )) || color(11);
867+ } elsif ($str eq " reset" ) {
868+ $ret = color(" reset" );
869+ } elsif ($str eq " add_line" ) {
870+ # Default ANSI green
871+ $ret = git_ansi_color(git_config(' color.diff.new' )) || color(" 2_bold" );
872+ } elsif ($str eq " remove_line" ) {
873+ # Default ANSI red
874+ $ret = git_ansi_color(git_config(' color.diff.old' )) || color(" 1_bold" );
875+ } elsif ($str eq " fragment" ) {
876+ $ret = git_ansi_color(git_config(' color.diff.frag' )) || color(" 13_bold" );
877+ } elsif ($str eq " last_function" ) {
878+ $ret = git_ansi_color(git_config(' color.diff.func' )) || color(" 146_bold" );
879+ }
881880
882- # Cache (memoize) the entry for later
883- $static_config -> {$str } = $ret ;
881+ # Cache (memoize) the entry for later
882+ $static_config -> {$str } = $ret ;
884883
885- return $ret ;
886- }
884+ return $ret ;
887885}
888886
889887# https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_colors_in_git
0 commit comments