git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ciaran McCreesh <ciaran.mccreesh@googlemail.com>
To: git@vger.kernel.org
Cc: Ciaran McCreesh <ciaran.mccreesh@googlemail.com>
Subject: [PATCH] Make git-add -i accept ranges like 7-
Date: Mon, 14 Jul 2008 19:06:24 +0100	[thread overview]
Message-ID: <1216058784-32584-1-git-send-email-ciaran.mccreesh@googlemail.com> (raw)

git-add -i ranges expect number-number. But for the supremely lazy, typing in
that second number when selecting "from patch 7 to the end" is wasted effort.
So treat an empty second number in a range as "until the last item".

Signed-off-by: Ciaran McCreesh <ciaran.mccreesh@googlemail.com>
---
 Documentation/git-add.txt |    5 +++--
 git-add--interactive.perl |    6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 46dd56c..3558905 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -187,8 +187,9 @@ update::
    "Update>>".  When the prompt ends with double '>>', you can
    make more than one selection, concatenated with whitespace or
    comma.  Also you can say ranges.  E.g. "2-5 7,9" to choose
-   2,3,4,5,7,9 from the list.  You can say '*' to choose
-   everything.
+   2,3,4,5,7,9 from the list.  If the second number in a range is
+   omitted, all remaining patches are taken.  E.g. "7-" to choose
+   7,8,9 from the list.  You can say '*' to choose everything.
 +
 What you chose are then highlighted with '*',
 like this:
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 801d7c0..72a8858 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -406,9 +406,9 @@ sub list_and_choose {
 			if ($choice =~ s/^-//) {
 				$choose = 0;
 			}
-			# A range can be specified like 5-7
-			if ($choice =~ /^(\d+)-(\d+)$/) {
-				($bottom, $top) = ($1, $2);
+			# A range can be specified like 5-7 or 5-.
+			if ($choice =~ /^(\d*)-(\d*)$/) {
+				($bottom, $top) = ($1, length($2) ? $2 : 1 + @stuff);
 			}
 			elsif ($choice =~ /^\d+$/) {
 				$bottom = $top = $choice;
-- 
1.5.6.2

             reply	other threads:[~2008-07-14 18:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-14 18:06 Ciaran McCreesh [this message]
2008-07-14 18:15 ` [PATCH] Make git-add -i accept ranges like 7- Junio C Hamano
2008-07-14 18:29   ` [PATCH,v2] " Ciaran McCreesh

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=1216058784-32584-1-git-send-email-ciaran.mccreesh@googlemail.com \
    --to=ciaran.mccreesh@googlemail.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).