From: Ciaran McCreesh Date: Mon, 14 Jul 2008 18:29:37 +0000 (+0100) Subject: Make git-add -i accept ranges like 7- X-Git-Tag: v1.5.6.5~11 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=69c231f4732e1373f7872dde6dc50ffe62673865;p=git.git Make git-add -i accept ranges like 7- 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 Signed-off-by: Junio C Hamano --- diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt index b8e3fa675..815864c37 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 903953e68..709caa905 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -394,9 +394,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;