Skip to content

Commit ac618c4

Browse files
phillipwoodgitster
authored andcommitted
add -p: disable stdin buffering when interactive.singlekey is set
The builtin "add -p" reads the key "F2" as three separate keys "^[", "O" and "Q". The "Q" causes it to quit which is probably not what the user was expecting. This is because it uses poll() to check for pending input when reading escape sequences but reads the input with getchar() which is buffered by default and so hoovers up all the pending input leading poll() think there isn't anything pending. Fix this by calling setbuf() to disable input buffering if interactive.singlekey is set. Looking at the comment above mingw_getchar() in terminal.c I wonder if that function is papering over this bug and could be removed. Unfortunately I don't have access to windows to test that. Signed-off-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2c68602 commit ac618c4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

add-interactive.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ void init_add_i_state(struct add_i_state *s, struct repository *r)
7070
&s->interactive_diff_algorithm);
7171

7272
git_config_get_bool("interactive.singlekey", &s->use_single_key);
73+
if (s->use_single_key)
74+
setbuf(stdin, NULL);
7375
}
7476

7577
void clear_add_i_state(struct add_i_state *s)

0 commit comments

Comments
 (0)