git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-add--interactive: print message if there are no untracked files

From
Alexander Kuleshov <kuleshovmail@gmail.com>
Date
Jan 22, 2015, 07:11 UTC
Message-ID
<CANCZXo5OQHNCyz3kUY6c0Y_Lpabee0WS+eQ5G53QupMLwOw=jg@mail.gmail.com>
In-Reply-To
<xmqqegqnx281.fsf@gitster.dls.corp.google.com>

No i don't see any reasons why list_and_choose() shoud give a prompt without candidates. Will resed patch.

Thank you.
2015-01-22 3:17 GMT+06:00 Junio C Hamano <gitster@pobox.com>:
Show 41 quoted lines
> 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};
>
-- 
_________________________
0xAX
Previous: Junio C Hamano
Message 4 of 4 in “git-add--interactive: print message if there are no untracked files”
  1. git-add--interactive: print message if there are no untracked filesAlexander Kuleshov, Jan 21, 2015
  2. Junio C HamanoJan 21, 2015
  3. Junio C HamanoJan 21, 2015
  4. Alexander KuleshovJan 22, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.