add -i (built-in): do show an error message for incorrect inputs
authorJohannes Schindelin <redacted>
Tue, 10 Nov 2020 23:42:11 +0000 (23:42 +0000)
committerJunio C Hamano <redacted>
Wed, 11 Nov 2020 01:00:15 +0000 (17:00 -0800)
commitd34e4502fa540ed0654df7dd75b3689c48015f1a
tree7e1d50dc7adfe2fe37610534c653093919aab0c8
parent898f80736c75878acc02dc55672317fcc0e0a5a6
add -i (built-in): do show an error message for incorrect inputs

There is a neat feature in `git add -i` where it allows users to select
items via unique prefixes.

In the built-in version of `git add -i`, we specifically sort the items
(unless they are already sorted) and then perform a binary search to
figure out whether the input constitutes a unique prefix. Unfortunately,
by mistake this code misidentifies matches even if the input string is
not actually a prefix of any item.

For example, in the initial menu, where there is a `status` and an
`update` command, the input `tadaa` was mistaken as a prefix of
`update`.

Let's fix this by looking a bit closer whether the input is actually a
prefix of the item at the found insert index.

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
add-interactive.c
git clone https://git.99rst.org/PROJECT