Re: What's in git.git (stable frozen)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jan 05, 2008 at 11:24:09PM -0500, Jeff King wrote:

> >  * Jeff's git-add--interactive change to always honor color.diff
> >    regardless of color.interactive.
> > 
> >    I'd probably apply this, along with the patch to redefine
> >    what color.interactive means.  "git am -i" could also learn
> >    to use colors in the future.
> 
> Here is the palette cleanup patch, on top of my others (it should still

And while tracking down the $fraginfo usage, I noticed that my original
patches introduce a bug. Fix is below (it is on top of palette cleanup).

I can also resubmit these in a more sensible order (palette cleanup,
then the other three squashed together) if you prefer.

-- >8 --
add--interactive: colorize split hunk fragment headers

The only diff element which we still color in perl is the
"fraginfo" for the split hunks. When honoring color.diff
without color.interactive, we were failing to actually color
this because the "colored" function checks for interactive
color. Instead, let's just color it by hand (the simple
approach is OK because we know we have a single line
string).

Signed-off-by: Jeff King <peff@xxxxxxxx>
---
This is a little uglier than it could be because the "colored" function
does two things: correctly colorize a string, and check the global
$use_color. We could do something like:

  local $use_color = 1;
  $display_head = colored($fraginfo_color, $head);

which is arguably less ugly. Or we could refactor "colored", which is a
larger change.

 git-add--interactive.perl |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 5bdcca8..76dc4e6 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -21,8 +21,8 @@ if ($use_color) {
 	$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");
 }
+$normal_color = $repo->get_color("", "reset");
 
 # Do we also set diff colors?
 $diff_use_color = $repo->get_colorbool('color.diff');
@@ -648,7 +648,8 @@ sub split_hunk {
 		my $display_head = $head;
 		unshift @{$hunk->{TEXT}}, $head;
 		if ($diff_use_color) {
-			$display_head = colored($fraginfo_color, $head);
+			$display_head = join('', $fraginfo_color, $head,
+				$normal_color, "\n");
 		}
 		unshift @{$hunk->{DISPLAY}}, $display_head;
 	}
-- 
1.5.4.rc2.1147.gaecdf-dirty

-
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

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux