mirror of
https://github.com/git/git.git
synced 2026-03-14 18:59:04 +01:00
Merge commit 'mingw/master' into devel
This commit is contained in:
@@ -3,42 +3,29 @@
|
||||
use strict;
|
||||
use Git;
|
||||
|
||||
# Prompt colors:
|
||||
my ($prompt_color, $header_color, $help_color, $normal_color);
|
||||
# Diff colors:
|
||||
my ($new_color, $old_color, $fraginfo_color, $metainfo_color, $whitespace_color);
|
||||
|
||||
my ($use_color, $diff_use_color);
|
||||
my $repo = Git->repository();
|
||||
|
||||
$use_color = $repo->get_colorbool('color.interactive');
|
||||
my $menu_use_color = $repo->get_colorbool('color.interactive');
|
||||
my ($prompt_color, $header_color, $help_color) =
|
||||
$menu_use_color ? (
|
||||
$repo->get_color('color.interactive.prompt', 'bold blue'),
|
||||
$repo->get_color('color.interactive.header', 'bold'),
|
||||
$repo->get_color('color.interactive.help', 'red bold'),
|
||||
) : ();
|
||||
|
||||
if ($use_color) {
|
||||
# Set interactive colors:
|
||||
my $diff_use_color = $repo->get_colorbool('color.diff');
|
||||
my ($fraginfo_color) =
|
||||
$diff_use_color ? (
|
||||
$repo->get_color('color.diff.frag', 'cyan'),
|
||||
) : ();
|
||||
|
||||
# Grab the 3 main colors in git color string format, with sane
|
||||
# (visible) defaults:
|
||||
$prompt_color = $repo->get_color("color.interactive.prompt", "bold blue");
|
||||
$header_color = $repo->get_color("color.interactive.header", "bold");
|
||||
$help_color = $repo->get_color("color.interactive.help", "red bold");
|
||||
$normal_color = $repo->get_color("", "reset");
|
||||
|
||||
# Do we also set diff colors?
|
||||
$diff_use_color = $repo->get_colorbool('color.diff');
|
||||
if ($diff_use_color) {
|
||||
$new_color = $repo->get_color("color.diff.new", "green");
|
||||
$old_color = $repo->get_color("color.diff.old", "red");
|
||||
$fraginfo_color = $repo->get_color("color.diff.frag", "cyan");
|
||||
$metainfo_color = $repo->get_color("color.diff.meta", "bold");
|
||||
$whitespace_color = $repo->get_color("color.diff.whitespace", "normal red");
|
||||
}
|
||||
}
|
||||
my $normal_color = $repo->get_color("", "reset");
|
||||
|
||||
sub colored {
|
||||
my $color = shift;
|
||||
my $string = join("", @_);
|
||||
|
||||
if ($use_color) {
|
||||
if (defined $color) {
|
||||
# Put a color code at the beginning of each line, a reset at the end
|
||||
# color after newlines that are not at the end of the string
|
||||
$string =~ s/(\n+)(.)/$1$color$2/g;
|
||||
@@ -304,7 +291,7 @@ sub highlight_prefix {
|
||||
return "$prefix$remainder";
|
||||
}
|
||||
|
||||
if (!$use_color) {
|
||||
if (!$menu_use_color) {
|
||||
return "[$prefix]$remainder";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user