add -p: fix checking of user input
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Mon, 17 Aug 2020 13:23:08 +0000 (13:23 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Aug 2020 18:44:42 +0000 (11:44 -0700)
commitce910287e727e5b534d806df725c68a8dfc4790a
treed4708f694646c2e8dd96d83bb8cce558bc4c2ad3
parent2ebe436c5531319e820571d04024f7bcae383450
add -p: fix checking of user input

When a file has been deleted the C version of add -p allows the user
to edit a hunk even though 'e' is not in the list of allowed
responses. (I think 'e' is disallowed because if the file is edited it
is no longer a deletion and we're not set up to rewrite the diff
header).

The invalid response was allowed because the test that determines
whether to display 'e' was not duplicated correctly in the code that
processes the user's choice. Fix this by using flags that are set when
constructing the prompt and checked when processing the user's choice
rather than repeating the check itself.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
add-patch.c