From: William Pursell <bill.pursell@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 5/5] Implement 'l' command to display summaries.
Date: Thu, 27 Nov 2008 21:10:34 +0000 [thread overview]
Message-ID: <492F0CCA.20905@gmail.com> (raw)
The summary information is in place to print out
the first added line (NEW), and the first removed
line (OLD), but it seems that just printing the
line number context is adequate. Perhaps one
could add config options to print OLD and NEW,
but this seems good enough for now.
---
git-add--interactive.perl | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index ae785e2..6a3d97d 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -824,6 +824,7 @@ sub help_patch_cmd {
y - stage this hunk
n - do not stage this hunk
a - stage this and all the remaining hunks in the file
+l - print a brief summary of all the hunks in the file
d - do not stage this hunk nor any of the remaining hunks in the file
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
@@ -861,6 +862,24 @@ sub patch_update_cmd {
}
}
+sub display_summaries {
+ my $index = shift;
+ my @hunk = @_;
+ my $i = 0;
+ print "'*' indicates current hunk. '+' stage, '-' don't stage\n";
+ for ( ; $i < @hunk; $i++ ) {
+ my $status = " ";
+ if( defined $hunk[$i]{USE} ) {
+ $status = $hunk[$i]{USE} ? "+" : "-";
+ }
+ printf "%s%d%s: %s",
+ $i == $index ? "*" : " ",
+ $i,
+ $status,
+ $hunk[$i]{SUMMARY}{LINE};
+ }
+}
+
sub patch_update_file {
my ($ix, $num);
my $path = shift;
@@ -904,7 +923,7 @@ sub patch_update_file {
while (1) {
my ($commands, $undecided, $i);
- $commands = 'ynad';
+ $commands = 'ynald';
if ($num <= $ix) {
$ix = 0;
@@ -961,6 +980,10 @@ sub patch_update_file {
}
next;
}
+ elsif ($line =~ /^l/i) {
+ display_summaries ($ix, @hunk);
+ next;
+ }
elsif ($line =~ /^d/i) {
while ($ix < $num) {
if (!defined $hunk[$ix]{USE}) {
--
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=492F0CCA.20905@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).