Re: [PATCH] Make git-add -i accept ranges like 7-

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ciaran McCreesh <ciaran.mccreesh@xxxxxxxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux