git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: William Pursell <bill.pursell@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 4/5] Adding SUMMARY lines to hunks.
Date: Thu, 27 Nov 2008 21:10:28 +0000	[thread overview]
Message-ID: <492F0CC4.7050805@gmail.com> (raw)



The idea is to add a command to allow the hunks to be listed
with a brief summary of each, with an option to determine
what the summary will entail.  The current thought is
to be able to display the line summary, the first new
line, and the first removed line.
---
  git-add--interactive.perl |   27 ++++++++++++++++++++++++++-
  1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 0d51cb2..ae785e2 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -553,7 +553,20 @@ sub parse_diff {

  	for (my $i = 0; $i < @diff; $i++) {
  		if ($diff[$i] =~ /^@@ /) {
-			push @hunk, { TEXT => [], DISPLAY => [] };
+			push @hunk,
+			{ TEXT => [], DISPLAY => [],
+				SUMMARY => {
+					 LINE => $diff[$i],
+					 NEW => undef,
+					 OLD => undef
+				}
+			};
+		}
+		if ($diff[$i] =~ /^\+/ and not $hunk[-1]{SUMMARY}{NEW}) {
+			$hunk[-1]{SUMMARY}{NEW} = $diff[$i];
+		}
+		if ($diff[$i] =~ /^-/ and not $hunk[-1]{SUMMARY}{OLD}) {
+			$hunk[-1]{SUMMARY}{OLD} = $diff[$i];
  		}
  		push @{$hunk[-1]{TEXT}}, $diff[$i];
  		push @{$hunk[-1]{DISPLAY}},
@@ -613,6 +626,11 @@ sub split_hunk {
  		my $this = +{
  			TEXT => [],
  			DISPLAY => [],
+			SUMMARY => {
+				 LINE => undef,
+				 NEW => undef,
+				 OLD => undef
+			},
  			OLD => $o_ofs,
  			NEW => $n_ofs,
  			OCNT => 0,
@@ -658,6 +676,12 @@ sub split_hunk {
  				push @split, $this;
  				redo OUTER;
  			}
+			if ($line =~ /\+/ and not $this->{SUMMARY}{NEW}) {
+				$this->{SUMMARY}{NEW} = $line;
+			}
+			if ($line =~ /-/ and not $this->{SUMMARY}{OLD}) {
+				$this->{SUMMARY}{OLD} = $line;
+			}
  			push @{$this->{TEXT}}, $line;
  			push @{$this->{DISPLAY}}, $display;
  			$this->{ADDDEL}++;
@@ -685,6 +709,7 @@ sub split_hunk {
  			    (($n_cnt != 1) ? ",$n_cnt" : '') .
  			    " @@\n");
  		my $display_head = $head;
+		$hunk->{SUMMARY}{LINE} = $head;
  		unshift @{$hunk->{TEXT}}, $head;
  		if ($diff_use_color) {
  			$display_head = colored($fraginfo_color, $head);
-- 
1.6.0.4.782.geea74.dirty


-- 
William Pursell

                 reply	other threads:[~2008-11-27 21:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=492F0CC4.7050805@gmail.com \
    --to=bill.pursell@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).