Re: [PATCH] git-add--interactive: print message if there are no untracked files
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 21, 2015, 21:11 UTC
- Message-ID
- <xmqqmw5bx2ii.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <1421867004-31672-1-git-send-email-kuleshovmail@gmail.com>
Alexander Kuleshov <kuleshovmail@gmail.com> writes:
> If user selects 'add untracked' and there are no untracked files, > "Add untracked>>" opens. But it does not make sense in this case, > because there are no untracked files. So let's print message and > exit from "add untracked" mode.
That reasoning makes perfect sense.
Show 19 quoted lines
> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
> ---
> git-add--interactive.perl | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index 94b988c..1a6dcf3 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -724,11 +724,15 @@ sub revert_cmd {
> }
>
> 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
my @add = list_untracked();
if (@add) {
@add = list_and_choose({...}, @add);
}
if (!@add) {
Nothing to do;
} else {
Run update-index
}or something instead?
Show 11 quoted lines
> + my @add = list_and_choose({ PROMPT => 'Add untracked' },
> + list_untracked());
> + if (@add) {
> + system(qw(git update-index --add --), @add);
> + say_n_paths('added', @add);
> + }
> + } else {
> + print "No untracked files.\n";
> }
> print "\n";
> }