diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-12-10 14:35:16 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-12-10 14:35:16 -0800 |
commit | 7d53ff402a9140663da8e1a7a330f14f0de02e65 (patch) | |
tree | aac3696f55b9c77f4f8af0faeb0a5ca8ef8e1211 /git-add--interactive.perl | |
parent | Merge branch 'cb/mingw-gmtime-r' (diff) | |
parent | add -p: avoid use of undefined $key when ReadKey -> EOF (diff) | |
download | tgif-7d53ff402a9140663da8e1a7a330f14f0de02e65.tar.xz |
Merge branch 'cb/add-p-single-key-fix'
The single-key-input mode in "git add -p" had some code to handle
keys that generate a sequence of input via ReadKey(), which did not
handle end-of-file correctly, which has been fixed.
* cb/add-p-single-key-fix:
add -p: avoid use of undefined $key when ReadKey -> EOF
Diffstat (limited to 'git-add--interactive.perl')
-rwxr-xr-x | git-add--interactive.perl | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/git-add--interactive.perl b/git-add--interactive.perl index bc3a1e8eff..95887fd8e5 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -1175,15 +1175,17 @@ sub prompt_single_character { ReadMode 'cbreak'; my $key = ReadKey 0; ReadMode 'restore'; - if ($use_termcap and $key eq "\e") { - while (!defined $term_escapes{$key}) { - my $next = ReadKey 0.5; - last if (!defined $next); - $key .= $next; + if (defined $key) { + if ($use_termcap and $key eq "\e") { + while (!defined $term_escapes{$key}) { + my $next = ReadKey 0.5; + last if (!defined $next); + $key .= $next; + } + $key =~ s/\e/^[/; } - $key =~ s/\e/^[/; + print "$key"; } - print "$key" if defined $key; print "\n"; return $key; } else { |