Re: [PATCH] Add config_int() method to the Git perl module

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] Add config_int() method to the Git perl module

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:53

Jakub Narebski [off-list ref] writes:
Integer variables can have optional 'k', 'm' or 'g' suffix.
config_int() method will return simple decimal number, taking
care of those suffixes.
Good.  I forgot about --int option to "git config" already.

Maybe in a similar way, we might want to add --color to "git
config" to return ANSI sequence, so that Git::config_color() can
work without even loading Term::ANSIColor?

Re: [PATCH] Add config_int() method to the Git perl module

From: Wincent Colaiuta <hidden>
Date: 2016-06-15 22:43:53

El 23/11/2007, a las 20:59, Junio C Hamano escribió:
Jakub Narebski [off-list ref] writes:
quoted
Integer variables can have optional 'k', 'm' or 'g' suffix.
config_int() method will return simple decimal number, taking
care of those suffixes.
Good.  I forgot about --int option to "git config" already.

Maybe in a similar way, we might want to add --color to "git
config" to return ANSI sequence, so that Git::config_color() can
work without even loading Term::ANSIColor?
Or failing that, it would be very easy to remove the dependency on  
Term::ANSIColor by adding something like this to Git.pm:

+my $COLOR = {
+       "reset"         => "\e[0m",
+       "normal"        => "",
+       "black"         => "\e[30m",
+       "red"           => "\e[31m",
+       "green"         => "\e[32m",
+       "yellow"        => "\e[33m",
+       "blue"          => "\e[34m",
+       "magenta"       => "\e[35m",
+       "cyan"          => "\e[36m",
+       "white"         => "\e[37m",
+       "bold"          => "\e[1m",
+       "ul"            => "\e[4m",
+       "blink"         => "\e[5m",
+       "reverse"       => "\e[7m",
+       "on_red"        => "\e[41m",
+};
+
+sub color {
+       my $desired_color = shift;
+       return $COLOR->{$desired_color} || "";
+}

Cheers,
Wincent

Re: [PATCH] Add config_int() method to the Git perl module

From: Jeff King <hidden>
Date: 2016-06-15 22:43:53

On Fri, Nov 23, 2007 at 11:59:25AM -0800, Junio C Hamano wrote:
Maybe in a similar way, we might want to add --color to "git
config" to return ANSI sequence, so that Git::config_color() can
work without even loading Term::ANSIColor?
We would also need a way of parsing the 'default' values, so git-config
would need a way of saying "turn this value into its internal
representation" (or the perl script would have to specify its defaults
as raw ANSI codes, which is a bit ugly, but is that the C programs do).

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help