1212 $repo -> get_color(' color.interactive.header' , ' bold' ),
1313 $repo -> get_color(' color.interactive.help' , ' red bold' ),
1414 ) : ();
15+ my $error_color = ();
16+ if ($menu_use_color ) {
17+ my $help_color_spec = $repo -> config(' color.interactive.help' );
18+ $error_color = $repo -> get_color(' color.interactive.error' ,
19+ $help_color_spec );
20+ }
1521
1622my $diff_use_color = $repo -> get_colorbool(' color.diff' );
1723my ($fraginfo_color ) =
@@ -333,6 +339,10 @@ sub highlight_prefix {
333339 return " $prompt_color$prefix$normal_color$remainder " ;
334340}
335341
342+ sub error_msg {
343+ print STDERR colored $error_color , @_ ;
344+ }
345+
336346sub list_and_choose {
337347 my ($opts , @stuff ) = @_ ;
338348 my (@chosen , @return );
@@ -428,12 +438,12 @@ sub list_and_choose {
428438 else {
429439 $bottom = $top = find_unique($choice , @stuff );
430440 if (!defined $bottom ) {
431- print " Huh ($choice )?\n " ;
441+ error_msg " Huh ($choice )?\n " ;
432442 next TOPLOOP;
433443 }
434444 }
435445 if ($opts -> {SINGLETON } && $bottom != $top ) {
436- print " Huh ($choice )?\n " ;
446+ error_msg " Huh ($choice )?\n " ;
437447 next TOPLOOP;
438448 }
439449 for ($i = $bottom -1; $i <= $top -1; $i ++) {
@@ -1029,11 +1039,11 @@ sub patch_update_file {
10291039 chomp $response ;
10301040 }
10311041 if ($response !~ / ^\s *\d +\s *$ / ) {
1032- print STDERR " Invalid number: '$response '\n " ;
1042+ error_msg " Invalid number: '$response '\n " ;
10331043 } elsif (0 < $response && $response <= $num ) {
10341044 $ix = $response - 1;
10351045 } else {
1036- print STDERR " Sorry, only $num hunks available.\n " ;
1046+ error_msg " Sorry, only $num hunks available.\n " ;
10371047 }
10381048 next ;
10391049 }
@@ -1062,7 +1072,7 @@ sub patch_update_file {
10621072 if ($@ ) {
10631073 my ($err ,$exp ) = ($@ , $1 );
10641074 $err =~ s / at .*git-add--interactive line \d +, <STDIN> line \d +.*$// ;
1065- print STDERR " Malformed search regexp $exp : $err \n " ;
1075+ error_msg " Malformed search regexp $exp : $err \n " ;
10661076 next ;
10671077 }
10681078 my $iy = $ix ;
@@ -1072,7 +1082,7 @@ sub patch_update_file {
10721082 $iy ++;
10731083 $iy = 0 if ($iy >= $num );
10741084 if ($ix == $iy ) {
1075- print STDERR " No hunk matches the given pattern\n " ;
1085+ error_msg " No hunk matches the given pattern\n " ;
10761086 last ;
10771087 }
10781088 }
@@ -1084,7 +1094,7 @@ sub patch_update_file {
10841094 $ix --;
10851095 }
10861096 else {
1087- print STDERR " No previous hunk\n " ;
1097+ error_msg " No previous hunk\n " ;
10881098 }
10891099 next ;
10901100 }
@@ -1093,7 +1103,7 @@ sub patch_update_file {
10931103 $ix ++;
10941104 }
10951105 else {
1096- print STDERR " No next hunk\n " ;
1106+ error_msg " No next hunk\n " ;
10971107 }
10981108 next ;
10991109 }
@@ -1106,13 +1116,13 @@ sub patch_update_file {
11061116 }
11071117 }
11081118 else {
1109- print STDERR " No previous hunk\n " ;
1119+ error_msg " No previous hunk\n " ;
11101120 }
11111121 next ;
11121122 }
11131123 elsif ($line =~ / ^j/ ) {
11141124 if ($other !~ / j/ ) {
1115- print STDERR " No next hunk\n " ;
1125+ error_msg " No next hunk\n " ;
11161126 next ;
11171127 }
11181128 }
0 commit comments