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

Re: Small issue with "add untracked" option of 'git add -i'

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 12, 2017, 17:38 UTC
Message-ID
<xmqqwp8hnm1v.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1497278015.7302.13.camel@gmail.com>
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> writes:
Show 21 quoted lines
> * He chooses to use 'git add -i' to stage changes
> * He chooses option 4, accidentally, instead of option 5. He is shown
> the following menu,
>
>> *** Commands ***
>>   1: status	  2: update	  3: revert	  4: add
>> untracked
>>   5: patch	  6: diff	  7: quit	  8: help
>> What now> 4
>>   1: test-file
>> Add untracked>> 
>
> * He exits by hitting return but he is shown this weird message found
> below.
>
>> No untracked files.
>
> * He is surprised on seeing this.
>
> Why is that message shown when "there are untracked files" but the user
> doesn't add them to the staging area?
It comes from this snippet in git-add--interactive.perl:
        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);
                } else {
                        print __("No untracked files.\n");
                }
                print "\n";
        }

After prompting to get the list of desired files, if the user chose nothing, the message is shown. "No untracked files chosen." is probably what the code wants to say, I would think.

 git-add--interactive.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 709a5f6ce6..98c9f20578 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -711,7 +711,7 @@ sub add_untracked_cmd {
 		system(qw(git update-index --add --), @add);
 		say_n_paths('added', @add);
 	} else {
-		print __("No untracked files.\n");
+		print __("No untracked file chosen.\n");
 	}
 	print "\n";
 }
Previous: Kaartic SivaraamNext: Kaartic Sivaraam
Message 2 of 10 in “Small issue with "add untracked" option of 'git add -i'”
  1. Kaartic SivaraamJun 12, 2017
  2. Junio C HamanoJun 12, 2017
  3. Kaartic SivaraamJun 12, 2017
  4. Junio C HamanoJun 12, 2017
  5. Kaartic SivaraamJun 14, 2017
  6. Kaartic SivaraamJun 15, 2017
  7. Kaartic SivaraamJun 21, 2017
  8. Kevin DaudtJun 21, 2017
  9. Kaartic SivaraamJun 21, 2017
  10. Kaartic SivaraamJun 22, 2017

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.