git-add--interactive: Allow Ctrl-D to exit
[gitweb.git] / git-add--interactive.perl
index 7921cde8cbd3b58f1d7222e9828bf85e10f363e3..f9e9f0239295c813be26392fe1299c7fc36ee004 100755 (executable)
@@ -213,7 +213,11 @@ sub list_and_choose {
                        print ">> ";
                }
                my $line = <STDIN>;
-               last if (!$line);
+               if (!$line) {
+                       print "\n";
+                       $opts->{ON_EOF}->() if $opts->{ON_EOF};
+                       last;
+               }
                chomp $line;
                my $donesomething = 0;
                for my $choice (split(/[\s,]+/, $line)) {
@@ -791,6 +795,7 @@ sub main_loop {
                                             SINGLETON => 1,
                                             LIST_FLAT => 4,
                                             HEADER => '*** Commands ***',
+                                            ON_EOF => \&quit_cmd,
                                             IMMEDIATE => 1 }, @cmd);
                if ($it) {
                        eval {