git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Kuleshov <kuleshovmail@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Alexander Kuleshov <kuleshovmail@gmail.com>
Subject: [PATCH] git-add--interactive: print message if there are no untracked files
Date: Thu, 22 Jan 2015 01:03:24 +0600	[thread overview]
Message-ID: <1421867004-31672-1-git-send-email-kuleshovmail@gmail.com> (raw)

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.

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 --))) {
+		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";
 }
-- 
2.3.0.rc1.247.gb53aa6f

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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-21 19:03 Alexander Kuleshov [this message]
2015-01-21 21:11 ` [PATCH] git-add--interactive: print message if there are no untracked files Junio C Hamano
2015-01-21 21:17   ` Junio C Hamano
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=1421867004-31672-1-git-send-email-kuleshovmail@gmail.com \
    --to=kuleshovmail@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).