@matheusbsbs / matheus-bagliano / commits / 1e5aaa6db3
Fork 0

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 <ciaran.mccreesh@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ciaran McCreesh committed Jul 14, 2008 at 19:29 UTC 1e5aaa6db38964fd6ca679864c0a40f7af01cf1a
2 files changed +6 -5
Documentation/git-add.txt
+3 -2
@@ -187,8 +187,9 @@ update::
187 "Update>>". When the prompt ends with double '>>', you can
188 make more than one selection, concatenated with whitespace or
189 comma. Also you can say ranges. E.g. "2-5 7,9" to choose
190 - 2,3,4,5,7,9 from the list. You can say '*' to choose
191 - everything.
190 + 2,3,4,5,7,9 from the list. If the second number in a range is
191 + omitted, all remaining patches are taken. E.g. "7-" to choose
192 + 7,8,9 from the list. You can say '*' to choose everything.
193 +
194 What you chose are then highlighted with '*',
195 like this:
git-add--interactive.perl
+3 -3
@@ -406,9 +406,9 @@ sub list_and_choose {
406 if ($choice =~ s/^-//) {
407 $choose = 0;
408 }
409 - # A range can be specified like 5-7
410 - if ($choice =~ /^(\d+)-(\d+)$/) {
411 - ($bottom, $top) = ($1, $2);
409 + # A range can be specified like 5-7 or 5-.
410 + if ($choice =~ /^(\d+)-(\d*)$/) {
411 + ($bottom, $top) = ($1, length($2) ? $2 : 1 + @stuff);
412 }
413 elsif ($choice =~ /^\d+$/) {
414 $bottom = $top = $choice;