add -p: trap Ctrl-D in 'goto' mode
authorThomas Rast <trast@student.ethz.ch>
Mon, 2 Feb 2009 21:46:29 +0000 (22:46 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Feb 2009 08:52:52 +0000 (00:52 -0800)
If the user hit Ctrl-D (EOF) while the script was in 'go to hunk?'
mode, it threw an undefined variable error.  Explicitly test for EOF
and have it re-enter the goto prompt loop.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-add--interactive.perl

index 551b4475b5a384e12fe2b616dfdbc093ab382081..3bf0cda4eef6714b09df0360d48c12796598071a 100755 (executable)
@@ -994,6 +994,9 @@ sub patch_update_file {
                                        }
                                        print "go to which hunk$extra? ";
                                        $response = <STDIN>;
+                                       if (!defined $response) {
+                                               $response = '';
+                                       }
                                        chomp $response;
                                }
                                if ($response !~ /^\s*\d+\s*$/) {