{"thread":{"id":"38427","subject":"[PATCH] git-add--interactive: return from list_and_choose if there is zero candidates","startedAt":"2015-01-22T08:39:44Z","lastAt":"2015-01-22T08:39:44Z","messageCount":1,"participants":["Alexander Kuleshov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"255072","messageId":"1421915984-31207-1-git-send-email-kuleshovmail@gmail.com","threadId":"38427","inReplyTo":null,"subject":"[PATCH] git-add--interactive: return from list_and_choose if there is zero candidates","fromName":"Alexander Kuleshov","fromEmail":"kuleshovmail@gmail.com","sentAt":"2015-01-22T08:39:44Z","receivedAt":"2015-01-22T08:39:44Z","isPatch":true,"sender":{"key":"kuleshovmail@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2699235?v=4"},"body":"This patch introduce the check in list_and_choose() routine for the list. If\nlist is empty just return.\n\nIt can be useful for example if user selects 'add untracked' and there are no\nuntracked files, \"Add untracked>>\" opens. But it does not make sense in this\ncase, because there are no untracked files.\n\nSigned-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n---\n git-add--interactive.perl | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 94b988c..85b2fe7 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -519,6 +519,9 @@ sub error_msg {\n sub list_and_choose {\n \tmy ($opts, @stuff) = @_;\n \tmy (@chosen, @return);\n+\tif (!@stuff) {\n+\t    return @return;\n+\t}\n \tmy $i;\n \tmy @prefixes = find_unique_prefixes(@stuff) unless $opts->{LIST_ONLY};\n \n@@ -729,6 +732,8 @@ sub add_untracked_cmd {\n \tif (@add) {\n \t\tsystem(qw(git update-index --add --), @add);\n \t\tsay_n_paths('added', @add);\n+\t} else {\n+\t\tprint \"No untracked files.\\n\";\n \t}\n \tprint \"\\n\";\n }\n-- \n2.3.0.rc1.247.gb53aa6f.dirty\n"}]}