From: Junio C Hamano <gitster@pobox.com>
To: Ciaran McCreesh <ciaran.mccreesh@googlemail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Make git-add -i accept ranges like 7-
Date: Mon, 14 Jul 2008 11:15:13 -0700 [thread overview]
Message-ID: <7vfxqcgwni.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1216058784-32584-1-git-send-email-ciaran.mccreesh@googlemail.com> (Ciaran McCreesh's message of "Mon, 14 Jul 2008 19:06:24 +0100")
Ciaran McCreesh <ciaran.mccreesh@googlemail.com> writes:
> 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".
You didn't describe why you changed the first regexp from \d+ to \d*,
which would allow "-9" as a valid input as well.
But in that case $bottom will become an empty string. Don't you need to
adjust the users of this data in the codepaths that follow this part? I
didn't check.
> 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
next prev parent reply other threads:[~2008-07-14 18:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-14 18:06 [PATCH] Make git-add -i accept ranges like 7- Ciaran McCreesh
2008-07-14 18:15 ` Junio C Hamano [this message]
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=7vfxqcgwni.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=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).