Junio C Hamano <gits...@pobox.com> writes:

>>  sub add_untracked_cmd {
>> -    my @add = list_and_choose({ PROMPT => 'Add untracked' },
>> -                              list_untracked());
>> -    if (@add) {
>> -            system(qw(git update-index --add --), @add);
>> -            say_n_paths('added', @add);
>> +    if (system(qw(git ls-files --others --exclude-standard --))) {
>
> But this ls-files invocation that knows too much about how
> list_untracked() computes things does not.
>
> Why not
> ...
> or something instead?

Actually, is there any case where list_and_choose() should give a
prompt to choose from zero candidates?

In other words, I am wondering if this affects other callers of
list_and_choose in any negative way.

 git-add--interactive.perl | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 94b988c..46ed9a7 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -519,6 +519,10 @@ 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};
 
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to