built-in add -i: accept open-ended ranges again
The interactive `add` command allows selecting multiple files for some of its sub-commands, via unique prefixes, indices or index ranges. When re-implementing `git add -i` in C, we even added a code comment talking about ranges with a missing end index, such as `2-`, but the code did not actually accept those, as pointed out in https://github.com/git-for-windows/git/issues/2466#issuecomment-574142760. Let's fix this, and add a test case to verify that this stays fixed forever. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
d660a30ceb
commit
849e43cc18
@ -328,7 +328,10 @@ static ssize_t list_and_choose(struct add_i_state *s,
|
||||
if (endp == p + sep)
|
||||
to = from + 1;
|
||||
else if (*endp == '-') {
|
||||
to = strtoul(++endp, &endp, 10);
|
||||
if (isdigit(*(++endp)))
|
||||
to = strtoul(endp, &endp, 10);
|
||||
else
|
||||
to = items->items.nr;
|
||||
/* extra characters after the range? */
|
||||
if (endp != p + sep)
|
||||
from = -1;
|
||||
|
||||
Reference in New Issue
Block a user