All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Alexander Kuleshov <kuleshovmail@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] git-add--interactive: print message if there are no untracked files
Date: Wed, 21 Jan 2015 13:17:50 -0800	[thread overview]
Message-ID: <xmqqegqnx281.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <xmqqmw5bx2ii.fsf@gitster.dls.corp.google.com> (Junio C. Hamano's message of "Wed, 21 Jan 2015 13:11:33 -0800")

Junio C Hamano <gitster@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};
 

  reply	other threads:[~2015-01-21 21:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-21 19:03 [PATCH] git-add--interactive: print message if there are no untracked files Alexander Kuleshov
2015-01-21 21:11 ` Junio C Hamano
2015-01-21 21:17   ` Junio C Hamano [this message]
2015-01-22  7:11     ` Alexander Kuleshov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqegqnx281.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=kuleshovmail@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.