Skip to content

Commit 1a5ab6a

Browse files
committed
fixup! built-in add -i: prepare for multi-selection commands
During a final review before submitting it, this developer stumbled over the fact that the result of `strtoul()` was decremented by one for `from`, but not for `to`. Let's add a code comment to stave off confusion. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 0cf5b03 commit 1a5ab6a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

add-interactive.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,15 @@ static ssize_t list_and_choose(struct add_i_state *s,
331331
to = items->items.nr;
332332
} else if (isdigit(*p)) {
333333
char *endp;
334-
/* A range can be specified like 5-7 or 5-. */
334+
/*
335+
* A range can be specified like 5-7 or 5-.
336+
*
337+
* Note: `from` is 0-based while the user input
338+
* is 1-based, hence we have to decrement by
339+
* one. We do not have to decrement `to` even
340+
* if it is 0-based because it is an exclusive
341+
* boundary.
342+
*/
335343
from = strtoul(p, &endp, 10) - 1;
336344
if (endp == p + sep)
337345
to = from + 1;

0 commit comments

Comments
 (0)