]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'cb/add-p-single-key-fix'
authorJunio C Hamano <gitster@pobox.com>
Fri, 10 Dec 2021 22:35:16 +0000 (14:35 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Dec 2021 22:35:16 +0000 (14:35 -0800)
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

git-add--interactive.perl

index bc3a1e8effa321bd40bb83170646b98ca7f2e968..95887fd8e52ae9b4f0d7397f220376d1c994cbc5 100755 (executable)
@@ -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 {