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
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Date
Jun 22, 2017, 03:13 UTC
Message-ID
<1498101195.1687.4.camel@gmail.com>
In-Reply-To
<xmqqshj5nl3o.fsf@gitster.mtv.corp.google.com>
On Mon, 2017-06-12 at 10:59 -0700, Junio C Hamano wrote:
Show 61 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
> 
> > 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.
> 
> 
> Together with your other wishes, perhaps something like this is what
> you have in mind.  The original tried to throw in a blank line as a
> separator to help interactive users to more easily tell the boundary
> of blocks of text, but it wasn't consistently doing so (e.g. "update"
> when nothing is dirty was very silent, while "status" gave one blank
> line that is supposed to be shown after the list of changed ones even
> when the list is empty).
> 
>  git-add--interactive.perl | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index 709a5f6ce6..0ec09361b4 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -537,7 +537,7 @@ sub list_and_choose {
>  				$last_lf = 1;
>  			}
>  		}
> -		if (!$last_lf) {
> +		if (@stuff && !$last_lf) {
>  			print "\n";
>  		}
>  
> @@ -634,7 +634,6 @@ sub prompt_help_cmd {
>  sub status_cmd {
>  	list_and_choose({ LIST_ONLY => 1, HEADER => $status_head },
>  			list_modified());
> -	print "\n";
>  }
>  
>  sub say_n_paths {
> @@ -667,7 +666,6 @@ sub update_cmd {
>  		       map { $_->{VALUE} } @update);
>  		say_n_paths('updated', @update);
>  	}
> -	print "\n";
>  }
>  
>  sub revert_cmd {
> @@ -701,7 +699,6 @@ sub revert_cmd {
>  		refresh();
>  		say_n_paths('reverted', @update);
>  	}
> -	print "\n";
>  }
>  
>  sub add_untracked_cmd {
> @@ -711,9 +708,8 @@ 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");

I guess I should take take back the following statement from my previous thread,

> That does seem to be a more apt message to be shown. It's
> unambiguous.

The ambiguity persists. It seems that 'Add untracked' is not differentiating between 'absence of untracked files' and 'not selecting any untracked files' currently. It seems to be the root cause of the ambiguity.

As a result the new message "No untracked file chosen." seems absurd when user tries to choose the '4: add untracked' option in 'git add -i' and there are no untracked files in his repository.

    $ git add -i
    *** Commands ***
      1: status    	      2: update    	      3: revert    	      4: add untracked
      5: patch    	      6: diff    	      7: quit    	      8: help
    What now> 4
    No untracked file chosen.
Show 5 quoted lines
>  	}
> -	print "\n";
>  }
>  
>  sub run_git_apply {
Previous: Kaartic Sivaraam
Message 10 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.