Merge branch 'ak/add-i-empty-candidates'
authorJunio C Hamano <gitster@pobox.com>
Tue, 17 Feb 2015 18:15:19 +0000 (10:15 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 17 Feb 2015 18:15:20 +0000 (10:15 -0800)
The interactive "show a list and let the user choose from it"
interface "add -i" used showed and prompted to the user even when
the candidate list was empty, against which the only "choice" the
user could have made was to choose nothing.

* ak/add-i-empty-candidates:
add -i: return from list_and_choose if there is no candidate

1  2 
git-add--interactive.perl
index c7256741cc2a28f333d6a9be5f12e248df99ed5e,f35b3e61527d3e1d6ec2b40b085e456e96b1c294..77876d433a1ba2384a690155b51dac8118fa27b4
@@@ -515,6 -515,9 +515,9 @@@ sub error_msg 
  sub list_and_choose {
        my ($opts, @stuff) = @_;
        my (@chosen, @return);
+       if (!@stuff) {
+           return @return;
+       }
        my $i;
        my @prefixes = find_unique_prefixes(@stuff) unless $opts->{LIST_ONLY};
  
@@@ -725,6 -728,8 +728,8 @@@ sub add_untracked_cmd 
        if (@add) {
                system(qw(git update-index --add --), @add);
                say_n_paths('added', @add);
+       } else {
+               print "No untracked files.\n";
        }
        print "\n";
  }
@@@ -1356,7 -1361,6 +1361,7 @@@ sub patch_update_file 
                  $patch_mode_flavour{TARGET},
                  " [y,n,q,a,d,/$other,?]? ";
                my $line = prompt_single_character;
 +              last unless defined $line;
                if ($line) {
                        if ($line =~ /^y/i) {
                                $hunk[$ix]{USE} = 1;