On Wed, Dec 05, 2007 at 06:05:05PM -0800, Junio C Hamano wrote: > This is mostly lifted from earlier series by Dan Zwell, but updated to > use "git config --get-color" and "git config --get-colorbool" to make it > simpler and more consistent with commands written in C. Looks mostly sane, except for the colorbool issues I mentioned in response to 2/3. > diff --git a/git-add--interactive.perl b/git-add--interactive.perl > index 335c2c6..1019a72 100755 > --- a/git-add--interactive.perl > +++ b/git-add--interactive.perl > [...] > + # 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"); diff.color support? BTW, I am nagging about this because we never resolved what should happen. I am fine with the answer being "we are dropping support now." > +sub colored { > + my $color = shift; > + my $string = join("", @_); > + > + if ($use_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; > + # reset before newlines > + $string =~ s/(\n+)/$normal_color$1/g; > + # codes at beginning and end (if necessary): > + $string =~ s/^/$color/; > + $string =~ s/$/$normal_color/ unless $string =~ /\n$/; > + } > + return $string; > +} I still think this should go into Git.pm; I believe git-svn could make use of it. > sub highlight_prefix { > my $prefix = shift; > my $remainder = shift; > - return $remainder unless defined $prefix; > - return is_valid_prefix($prefix) ? > - "[$prefix]$remainder" : > - "$prefix$remainder"; > + > + if (!defined $prefix) { > + return $remainder; > + } > + > + if (!is_valid_prefix($prefix)) { > + return "$prefix$remainder"; > + } > + > + if (!$use_color) { > + return "[$prefix]$remainder"; > + } > + > + return "$prompt_color$prefix$normal_color$remainder"; Honestly, I find this blue+white coloring of the prefixes a bit ugly, but that is not your fault. :) -Peff - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html