Re: Subject: [PATCH 2/3] Let git-add--interactive read colors from .gitconfig

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Dan Zwell <dzwell@...>
Cc: Jeff King <peff@...>, Shawn O. Pearce <spearce@...>, Wincent Colaiuta <win@...>, Git Mailing List <git@...>, Jonathan del Strother <maillist@...>, Johannes Schindelin <Johannes.Schindelin@...>, Frank Lichtenheld <frank@...>
Date: Sunday, November 11, 2007 - 5:53 am

Dan Zwell <dzwell@zwell.net> writes:


Makes me wonder if you are better off with two new helper
functions defined in Git.pm, as in:

	$prompt_color = $repo->config_color("interactive.prompt") || "bold blue")
	$normal_color = Git::color_to_ansi_code("normal");


I do not like a hash variable name that says it is a "mapping".
It being a hash is enough indication that it is a mapping.

You are better off naming such a mapping as if it is a function
that takes one parameter (in this case, git name) and returns a
single value (perl name).  So I'd probably say:

	my %perl_attrib = ( ... );

(or "git_attrib_to_perl").  A use site of such a hash would look
like this:

	push @perl_words, $perl_attrib{'ul'};
        push @perl_names, $git_attrib_to_perl{'blink'};

Maybe it is just me, but aren't these easier to read?


	$word eq 'normal' ?


	exists $color_name{$word}

with

	my %color_name = map { $_ => 1 } qw(black red ... white);

at the beginning?


	exists $git_attrib_to_perl{$word}

?
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Color support added to git-add--interactive., Dan Zwell, (Sat Oct 13, 12:13 am)
Re: [PATCH] Color support added to git-add--interactive., Johannes Schindelin, (Sat Oct 13, 8:25 am)
Re: [PATCH] Color support added to git-add--interactive., Frank Lichtenheld, (Sat Oct 13, 8:49 am)
Re: [PATCH] Color support added to git-add--interactive., Wincent Colaiuta, (Sat Oct 13, 10:45 am)
Re: [PATCH] Color support added to git-add--interactive., Johannes Schindelin, (Sat Oct 13, 12:38 pm)
Re: [PATCH] Color support added to git-add--interactive., Jean-Luc Herren, (Sat Oct 13, 12:38 pm)
Re: [PATCH] Color support added to git-add--interactive., Wincent Colaiuta, (Sat Oct 13, 1:14 pm)
Re: [PATCH] Color support added to git-add--interactive., Andreas Ericsson, (Sat Oct 13, 2:31 pm)
Re: [PATCH] Color support added to git-add--interactive., Wincent Colaiuta, (Sat Oct 13, 4:36 pm)
Re: [PATCH] Color support added to git-add--interactive., Jean-Luc Herren, (Sat Oct 13, 6:23 pm)
Re: Subject: [PATCH 2/3] Let git-add--interactive read color..., Junio C Hamano, (Sun Nov 11, 5:53 am)
[PATCH 0/3] Adding colors to git-add--interactive, Dan Zwell, (Sat Nov 10, 10:21 pm)
[PATCH 0/3] Adding colors to git-add--interactive, Dan Zwell, (Sat Nov 10, 8:01 pm)
[PATCH 0/5] Colors for git-add--interactive, Dan Zwell, (Thu Nov 22, 6:54 am)
Re: [PATCH 0/5] Colors for git-add--interactive, Junio C Hamano, (Thu Nov 22, 3:20 pm)
Re: [PATCH 0/5] Colors for git-add--interactive, Jeff King, (Thu Nov 22, 7:57 am)
Re: [PATCH 0/3] Adding colors to git-add--interactive, Junio C Hamano, (Sun Nov 11, 4:23 am)