Skip to content

Commit 69c231f

Browse files
ciaranmgitster
authored andcommitted
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>
1 parent 1ceb95c commit 69c231f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Documentation/git-add.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,9 @@ update::
187187
"Update>>". When the prompt ends with double '>>', you can
188188
make more than one selection, concatenated with whitespace or
189189
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.
192193
+
193194
What you chose are then highlighted with '*',
194195
like this:

git-add--interactive.perl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,9 @@ sub list_and_choose {
394394
if ($choice =~ s/^-//) {
395395
$choose = 0;
396396
}
397-
# A range can be specified like 5-7
398-
if ($choice =~ /^(\d+)-(\d+)$/) {
399-
($bottom, $top) = ($1, $2);
397+
# A range can be specified like 5-7 or 5-.
398+
if ($choice =~ /^(\d+)-(\d*)$/) {
399+
($bottom, $top) = ($1, length($2) ? $2 : 1 + @stuff);
400400
}
401401
elsif ($choice =~ /^\d+$/) {
402402
$bottom = $top = $choice;

0 commit comments

Comments
 (0)