All of lore.kernel.org
 help / color / mirror / Atom feed
* Small issue with "add untracked" option of 'git add -i'
@ 2017-06-12 14:33 Kaartic Sivaraam
  2017-06-12 17:38 ` Junio C Hamano
  0 siblings, 1 reply; 10+ messages in thread
From: Kaartic Sivaraam @ 2017-06-12 14:33 UTC (permalink / raw)
  To: git

Hello all,

There seems to be a small issue with the output of the "add untracked"
option of 'git add -i'. Consider the following scenario,

* A user makes a change to a tracked file
* His repo has a few untracked files which he has left it in that way
intentionally
* 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 ? If that message is relative to
the staging area shouldn't it be made more explicit? Further in that
case it doesn't seem to be consistent with the another output shown in
the scenario in which the developer chooses the 'add untracked' option
when he really doesn't have any untracked files in his working
directory.

> *** Commands ***
>   1: status	  2: update	  3: revert	  4: add
> untracked
>   5: patch	  6: diff	  7: quit	  8: help
> What now> 4
> No untracked files.
> 


-- 
Regards,
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Small issue with "add untracked" option of 'git add -i'
  2017-06-12 14:33 Small issue with "add untracked" option of 'git add -i' Kaartic Sivaraam
@ 2017-06-12 17:38 ` Junio C Hamano
  2017-06-12 17:58   ` Kaartic Sivaraam
  2017-06-12 17:59   ` Junio C Hamano
  0 siblings, 2 replies; 10+ messages in thread
From: Junio C Hamano @ 2017-06-12 17:38 UTC (permalink / raw)
  To: Kaartic Sivaraam; +Cc: git

Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> writes:

> * 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";
 }

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: Small issue with "add untracked" option of 'git add -i'
  2017-06-12 17:38 ` Junio C Hamano
@ 2017-06-12 17:58   ` Kaartic Sivaraam
  2017-06-12 17:59   ` Junio C Hamano
  1 sibling, 0 replies; 10+ messages in thread
From: Kaartic Sivaraam @ 2017-06-12 17:58 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Mon, 2017-06-12 at 10:38 -0700, Junio C Hamano wrote:
> 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.
> 
That does seem to be a more apt message to be shown. It's unambiguous.

-- 
Regards,
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Small issue with "add untracked" option of 'git add -i'
  2017-06-12 17:38 ` Junio C Hamano
  2017-06-12 17:58   ` Kaartic Sivaraam
@ 2017-06-12 17:59   ` Junio C Hamano
  2017-06-14 13:04     ` Kaartic Sivaraam
                       ` (2 more replies)
  1 sibling, 3 replies; 10+ messages in thread
From: Junio C Hamano @ 2017-06-12 17:59 UTC (permalink / raw)
  To: Kaartic Sivaraam; +Cc: git

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");
 	}
-	print "\n";
 }
 
 sub run_git_apply {

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: Small issue with "add untracked" option of 'git add -i'
  2017-06-12 17:59   ` Junio C Hamano
@ 2017-06-14 13:04     ` Kaartic Sivaraam
  2017-06-15  6:50       ` Kaartic Sivaraam
  2017-06-21  2:55     ` Kaartic Sivaraam
  2017-06-22  3:13     ` Kaartic Sivaraam
  2 siblings, 1 reply; 10+ messages in thread
From: Kaartic Sivaraam @ 2017-06-14 13:04 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Mon, 2017-06-12 at 10:59 -0700, Junio C Hamano wrote:
> 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).
> 
That's right. Though I'm not sure of the implementation, I guess the
following patch would make `git add -i` do what I thought it should.

>  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");
>  	}
> -	print "\n";
>  }
>  
>  sub run_git_apply {

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Small issue with "add untracked" option of 'git add -i'
  2017-06-14 13:04     ` Kaartic Sivaraam
@ 2017-06-15  6:50       ` Kaartic Sivaraam
  0 siblings, 0 replies; 10+ messages in thread
From: Kaartic Sivaraam @ 2017-06-15  6:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Wed, 2017-06-14 at 18:34 +0530, Kaartic Sivaraam wrote:
> That's right. Though I'm not sure of the implementation, I guess the
> following patch would make `git add -i` do what I thought it should.
> 
A possible, probably better,  alternative would be to make the empty
state output more interactive. i.e., making all the options of `git add
-i` to output some useful message (something similar to the one printed
by the `add untracked` option currently.

-- 
Regards,
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Small issue with "add untracked" option of 'git add -i'
  2017-06-12 17:59   ` Junio C Hamano
  2017-06-14 13:04     ` Kaartic Sivaraam
@ 2017-06-21  2:55     ` Kaartic Sivaraam
  2017-06-21  4:52       ` Kevin Daudt
  2017-06-22  3:13     ` Kaartic Sivaraam
  2 siblings, 1 reply; 10+ messages in thread
From: Kaartic Sivaraam @ 2017-06-21  2:55 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Mon, 2017-06-12 at 10:59 -0700, Junio C Hamano wrote:
> 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");
>  	}
> -	print "\n";
>  }
>  
>  sub run_git_apply {

I tried applying the patch and building it locally. For some reason I
couldn't see the change in effect. What could I be missing?

-- 
Regards,
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Small issue with "add untracked" option of 'git add -i'
  2017-06-21  2:55     ` Kaartic Sivaraam
@ 2017-06-21  4:52       ` Kevin Daudt
  2017-06-21 12:05         ` Kaartic Sivaraam
  0 siblings, 1 reply; 10+ messages in thread
From: Kevin Daudt @ 2017-06-21  4:52 UTC (permalink / raw)
  To: Kaartic Sivaraam; +Cc: Junio C Hamano, git

On Wed, Jun 21, 2017 at 08:25:26AM +0530, Kaartic Sivaraam wrote:
> 
> I tried applying the patch and building it locally. For some reason I
> couldn't see the change in effect. What could I be missing?
> 

Did you make sure you used the git you built, and also the relevant
subcommands?

What does `which git` and git --exec-path return?

If you did not install git, but try to run it in the compiled dir, you
can better run bin-wrappers/git, which will make sure the correct sub
commands are run.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Small issue with "add untracked" option of 'git add -i'
  2017-06-21  4:52       ` Kevin Daudt
@ 2017-06-21 12:05         ` Kaartic Sivaraam
  0 siblings, 0 replies; 10+ messages in thread
From: Kaartic Sivaraam @ 2017-06-21 12:05 UTC (permalink / raw)
  To: Kevin Daudt; +Cc: Junio C Hamano, git

On Wed, 2017-06-21 at 06:52 +0200, Kevin Daudt wrote:
> Did you make sure you used the git you built, and also the relevant
> subcommands?
> 
You got it. I apologise for any confusion caused here. I seemed to have
accidentally given a build location in my custom build script,
different from the one that I assumed. I didn't identify it all along
as there was a previous build in the assumed location. Anyways, thanks
for pointing that out.

> What does `which git` and git --exec-path return?
> 
> If you did not install git, but try to run it in the compiled dir,
> you
> can better run bin-wrappers/git, which will make sure the correct sub
> commands are run.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Small issue with "add untracked" option of 'git add -i'
  2017-06-12 17:59   ` Junio C Hamano
  2017-06-14 13:04     ` Kaartic Sivaraam
  2017-06-21  2:55     ` Kaartic Sivaraam
@ 2017-06-22  3:13     ` Kaartic Sivaraam
  2 siblings, 0 replies; 10+ messages in thread
From: Kaartic Sivaraam @ 2017-06-22  3:13 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git


On Mon, 2017-06-12 at 10:59 -0700, Junio C Hamano wrote:
> 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.


>  	}
> -	print "\n";
>  }
>  
>  sub run_git_apply {


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-06-22  3:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-12 14:33 Small issue with "add untracked" option of 'git add -i' Kaartic Sivaraam
2017-06-12 17:38 ` Junio C Hamano
2017-06-12 17:58   ` Kaartic Sivaraam
2017-06-12 17:59   ` Junio C Hamano
2017-06-14 13:04     ` Kaartic Sivaraam
2017-06-15  6:50       ` Kaartic Sivaraam
2017-06-21  2:55     ` Kaartic Sivaraam
2017-06-21  4:52       ` Kevin Daudt
2017-06-21 12:05         ` Kaartic Sivaraam
2017-06-22  3:13     ` Kaartic Sivaraam

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.