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

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

From
Alexander Kuleshov <kuleshovmail@gmail.com>
Date
Jan 21, 2015, 19:03 UTC
Message-ID
<1421867004-31672-1-git-send-email-kuleshovmail@gmail.com>

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
Next: Junio C Hamano
Message 1 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.