* [PATCH 4/5] Adding SUMMARY lines to hunks.
@ 2008-11-27 21:10 William Pursell
0 siblings, 0 replies; only message in thread
From: William Pursell @ 2008-11-27 21:10 UTC (permalink / raw)
To: git
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-11-27 21:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-27 21:10 [PATCH 4/5] Adding SUMMARY lines to hunks William Pursell
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).