{"thread":{"id":"16507","subject":"[PATCH 4/5] Adding SUMMARY lines to hunks.","startedAt":"2008-11-27T21:10:28Z","lastAt":"2008-11-27T21:10:28Z","messageCount":1,"participants":["William Pursell"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"96638","messageId":"492F0CC4.7050805@gmail.com","threadId":"16507","inReplyTo":null,"subject":"[PATCH 4/5] Adding SUMMARY lines to hunks.","fromName":"William Pursell","fromEmail":"bill.pursell@gmail.com","sentAt":"2008-11-27T21:10:28Z","receivedAt":"2008-11-27T21:10:28Z","isPatch":true,"sender":{"key":"bill.pursell@gmail.com","avatar":"https://gravatar.com/avatar/3ab4313e5dfdc1fedb65206d829ba33f71f56f26e11326979d1b99d5e1c403c9?d=mp&s=160"},"body":"\n\nThe idea is to add a command to allow the hunks to be listed\nwith a brief summary of each, with an option to determine\nwhat the summary will entail.  The current thought is\nto be able to display the line summary, the first new\nline, and the first removed line.\n---\n  git-add--interactive.perl |   27 ++++++++++++++++++++++++++-\n  1 files changed, 26 insertions(+), 1 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 0d51cb2..ae785e2 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -553,7 +553,20 @@ sub parse_diff {\n\n  \tfor (my $i = 0; $i < @diff; $i++) {\n  \t\tif ($diff[$i] =~ /^@@ /) {\n-\t\t\tpush @hunk, { TEXT => [], DISPLAY => [] };\n+\t\t\tpush @hunk,\n+\t\t\t{ TEXT => [], DISPLAY => [],\n+\t\t\t\tSUMMARY => {\n+\t\t\t\t\t LINE => $diff[$i],\n+\t\t\t\t\t NEW => undef,\n+\t\t\t\t\t OLD => undef\n+\t\t\t\t}\n+\t\t\t};\n+\t\t}\n+\t\tif ($diff[$i] =~ /^\\+/ and not $hunk[-1]{SUMMARY}{NEW}) {\n+\t\t\t$hunk[-1]{SUMMARY}{NEW} = $diff[$i];\n+\t\t}\n+\t\tif ($diff[$i] =~ /^-/ and not $hunk[-1]{SUMMARY}{OLD}) {\n+\t\t\t$hunk[-1]{SUMMARY}{OLD} = $diff[$i];\n  \t\t}\n  \t\tpush @{$hunk[-1]{TEXT}}, $diff[$i];\n  \t\tpush @{$hunk[-1]{DISPLAY}},\n@@ -613,6 +626,11 @@ sub split_hunk {\n  \t\tmy $this = +{\n  \t\t\tTEXT => [],\n  \t\t\tDISPLAY => [],\n+\t\t\tSUMMARY => {\n+\t\t\t\t LINE => undef,\n+\t\t\t\t NEW => undef,\n+\t\t\t\t OLD => undef\n+\t\t\t},\n  \t\t\tOLD => $o_ofs,\n  \t\t\tNEW => $n_ofs,\n  \t\t\tOCNT => 0,\n@@ -658,6 +676,12 @@ sub split_hunk {\n  \t\t\t\tpush @split, $this;\n  \t\t\t\tredo OUTER;\n  \t\t\t}\n+\t\t\tif ($line =~ /\\+/ and not $this->{SUMMARY}{NEW}) {\n+\t\t\t\t$this->{SUMMARY}{NEW} = $line;\n+\t\t\t}\n+\t\t\tif ($line =~ /-/ and not $this->{SUMMARY}{OLD}) {\n+\t\t\t\t$this->{SUMMARY}{OLD} = $line;\n+\t\t\t}\n  \t\t\tpush @{$this->{TEXT}}, $line;\n  \t\t\tpush @{$this->{DISPLAY}}, $display;\n  \t\t\t$this->{ADDDEL}++;\n@@ -685,6 +709,7 @@ sub split_hunk {\n  \t\t\t    (($n_cnt != 1) ? \",$n_cnt\" : '') .\n  \t\t\t    \" @@\\n\");\n  \t\tmy $display_head = $head;\n+\t\t$hunk->{SUMMARY}{LINE} = $head;\n  \t\tunshift @{$hunk->{TEXT}}, $head;\n  \t\tif ($diff_use_color) {\n  \t\t\t$display_head = colored($fraginfo_color, $head);\n-- \n1.6.0.4.782.geea74.dirty\n\n\n-- \nWilliam Pursell\n"}]}