Skip to content
/ git Public
forked from git/git

Commit

Permalink
Make git-add -i accept ranges like 7-
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ciaranm authored and gitster committed Aug 2, 2008
1 parent 1ceb95c commit 69c231f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Documentation/git-add.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions git-add--interactive.perl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 69c231f

Please sign in to comment.