{"thread":{"id":"46159","subject":"Small issue with \"add untracked\" option of 'git add -i'","startedAt":"2017-06-12T14:34:02Z","lastAt":"2017-06-22T03:13:31Z","messageCount":10,"participants":["Kaartic Sivaraam","Junio C Hamano","Kevin Daudt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"321955","messageId":"1497278015.7302.13.camel@gmail.com","threadId":"46159","inReplyTo":null,"subject":"Small issue with \"add untracked\" option of 'git add -i'","fromName":"Kaartic Sivaraam","fromEmail":"kaarticsivaraam91196@gmail.com","sentAt":"2017-06-12T14:33:35Z","receivedAt":"2017-06-12T14:34:02Z","isPatch":false,"sender":{"key":"kaartic.sivaraam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12448084?v=4"},"body":"Hello all,\n\nThere seems to be a small issue with the output of the \"add untracked\"\noption of 'git add -i'. Consider the following scenario,\n\n* A user makes a change to a tracked file\n* His repo has a few untracked files which he has left it in that way\nintentionally\n* He chooses to use 'git add -i' to stage changes\n* He chooses option 4, accidentally, instead of option 5. He is shown\nthe following menu,\n\n> *** Commands ***\n>   1: status\t  2: update\t  3: revert\t  4: add\n> untracked\n>   5: patch\t  6: diff\t  7: quit\t  8: help\n> What now> 4\n>   1: test-file\n> Add untracked>> \n\n* He exits by hitting return but he is shown this weird message found\nbelow.\n\n> No untracked files.\n\n* He is surprised on seeing this.\n\nWhy is that message shown when \"there are untracked files\" but the user\ndoesn't add them to the staging area ? If that message is relative to\nthe staging area shouldn't it be made more explicit? Further in that\ncase it doesn't seem to be consistent with the another output shown in\nthe scenario in which the developer chooses the 'add untracked' option\nwhen he really doesn't have any untracked files in his working\ndirectory.\n\n> *** Commands ***\n>   1: status\t  2: update\t  3: revert\t  4: add\n> untracked\n>   5: patch\t  6: diff\t  7: quit\t  8: help\n> What now> 4\n> No untracked files.\n> \n\n\n-- \nRegards,\nKaartic Sivaraam <kaarticsivaraam91196@gmail.com>\n"},{"id":"321969","messageId":"xmqqwp8hnm1v.fsf@gitster.mtv.corp.google.com","threadId":"46159","inReplyTo":"1497278015.7302.13.camel@gmail.com","subject":"Re: Small issue with \"add untracked\" option of 'git add -i'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-12T17:38:36Z","receivedAt":"2017-06-12T17:38:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> writes:\n\n> * He chooses to use 'git add -i' to stage changes\n> * He chooses option 4, accidentally, instead of option 5. He is shown\n> the following menu,\n>\n>> *** Commands ***\n>>   1: status\t  2: update\t  3: revert\t  4: add\n>> untracked\n>>   5: patch\t  6: diff\t  7: quit\t  8: help\n>> What now> 4\n>>   1: test-file\n>> Add untracked>> \n>\n> * He exits by hitting return but he is shown this weird message found\n> below.\n>\n>> No untracked files.\n>\n> * He is surprised on seeing this.\n>\n> Why is that message shown when \"there are untracked files\" but the user\n> doesn't add them to the staging area?\n\nIt comes from this snippet in git-add--interactive.perl:\n\n        sub add_untracked_cmd {\n                my @add = list_and_choose({ PROMPT => __('Add untracked') },\n                                          list_untracked());\n                if (@add) {\n                        system(qw(git update-index --add --), @add);\n                        say_n_paths('added', @add);\n                } else {\n                        print __(\"No untracked files.\\n\");\n                }\n                print \"\\n\";\n        }\n\n\nAfter prompting to get the list of desired files, if the user chose\nnothing, the message is shown.  \"No untracked files chosen.\" is\nprobably what the code wants to say, I would think.\n\n git-add--interactive.perl | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 709a5f6ce6..98c9f20578 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -711,7 +711,7 @@ sub add_untracked_cmd {\n \t\tsystem(qw(git update-index --add --), @add);\n \t\tsay_n_paths('added', @add);\n \t} else {\n-\t\tprint __(\"No untracked files.\\n\");\n+\t\tprint __(\"No untracked file chosen.\\n\");\n \t}\n \tprint \"\\n\";\n }\n"},{"id":"321972","messageId":"1497290317.11486.4.camel@gmail.com","threadId":"46159","inReplyTo":"xmqqwp8hnm1v.fsf@gitster.mtv.corp.google.com","subject":"Re: Small issue with \"add untracked\" option of 'git add -i'","fromName":"Kaartic Sivaraam","fromEmail":"kaarticsivaraam91196@gmail.com","sentAt":"2017-06-12T17:58:37Z","receivedAt":"2017-06-12T17:59:04Z","isPatch":false,"sender":{"key":"kaartic.sivaraam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12448084?v=4"},"body":"On Mon, 2017-06-12 at 10:38 -0700, Junio C Hamano wrote:\n> After prompting to get the list of desired files, if the user chose\n> nothing, the message is shown.  \"No untracked files chosen.\" is\n> probably what the code wants to say, I would think.\n> \nThat does seem to be a more apt message to be shown. It's unambiguous.\n\n-- \nRegards,\nKaartic Sivaraam <kaarticsivaraam91196@gmail.com>\n"},{"id":"321973","messageId":"xmqqshj5nl3o.fsf@gitster.mtv.corp.google.com","threadId":"46159","inReplyTo":"xmqqwp8hnm1v.fsf@gitster.mtv.corp.google.com","subject":"Re: Small issue with \"add untracked\" option of 'git add -i'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-06-12T17:59:07Z","receivedAt":"2017-06-12T17:59:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> After prompting to get the list of desired files, if the user chose\n> nothing, the message is shown.  \"No untracked files chosen.\" is\n> probably what the code wants to say, I would think.\n\n\nTogether with your other wishes, perhaps something like this is what\nyou have in mind.  The original tried to throw in a blank line as a\nseparator to help interactive users to more easily tell the boundary\nof blocks of text, but it wasn't consistently doing so (e.g. \"update\"\nwhen nothing is dirty was very silent, while \"status\" gave one blank\nline that is supposed to be shown after the list of changed ones even\nwhen the list is empty).\n\n git-add--interactive.perl | 8 ++------\n 1 file changed, 2 insertions(+), 6 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 709a5f6ce6..0ec09361b4 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -537,7 +537,7 @@ sub list_and_choose {\n \t\t\t\t$last_lf = 1;\n \t\t\t}\n \t\t}\n-\t\tif (!$last_lf) {\n+\t\tif (@stuff && !$last_lf) {\n \t\t\tprint \"\\n\";\n \t\t}\n \n@@ -634,7 +634,6 @@ sub prompt_help_cmd {\n sub status_cmd {\n \tlist_and_choose({ LIST_ONLY => 1, HEADER => $status_head },\n \t\t\tlist_modified());\n-\tprint \"\\n\";\n }\n \n sub say_n_paths {\n@@ -667,7 +666,6 @@ sub update_cmd {\n \t\t       map { $_->{VALUE} } @update);\n \t\tsay_n_paths('updated', @update);\n \t}\n-\tprint \"\\n\";\n }\n \n sub revert_cmd {\n@@ -701,7 +699,6 @@ sub revert_cmd {\n \t\trefresh();\n \t\tsay_n_paths('reverted', @update);\n \t}\n-\tprint \"\\n\";\n }\n \n sub add_untracked_cmd {\n@@ -711,9 +708,8 @@ sub add_untracked_cmd {\n \t\tsystem(qw(git update-index --add --), @add);\n \t\tsay_n_paths('added', @add);\n \t} else {\n-\t\tprint __(\"No untracked files.\\n\");\n+\t\tprint __(\"No untracked file chosen.\\n\");\n \t}\n-\tprint \"\\n\";\n }\n \n sub run_git_apply {\n"},{"id":"322247","messageId":"1497445448.2678.1.camel@gmail.com","threadId":"46159","inReplyTo":"xmqqshj5nl3o.fsf@gitster.mtv.corp.google.com","subject":"Re: Small issue with \"add untracked\" option of 'git add -i'","fromName":"Kaartic Sivaraam","fromEmail":"kaarticsivaraam91196@gmail.com","sentAt":"2017-06-14T13:04:08Z","receivedAt":"2017-06-14T13:04:58Z","isPatch":false,"sender":{"key":"kaartic.sivaraam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12448084?v=4"},"body":"On Mon, 2017-06-12 at 10:59 -0700, Junio C Hamano wrote:\n> Together with your other wishes, perhaps something like this is what\n> you have in mind.  The original tried to throw in a blank line as a\n> separator to help interactive users to more easily tell the boundary\n> of blocks of text, but it wasn't consistently doing so (e.g. \"update\"\n> when nothing is dirty was very silent, while \"status\" gave one blank\n> line that is supposed to be shown after the list of changed ones even\n> when the list is empty).\n> \nThat's right. Though I'm not sure of the implementation, I guess the\nfollowing patch would make `git add -i` do what I thought it should.\n\n>  git-add--interactive.perl | 8 ++------\n>  1 file changed, 2 insertions(+), 6 deletions(-)\n> \n> diff --git a/git-add--interactive.perl b/git-add--interactive.perl\n> index 709a5f6ce6..0ec09361b4 100755\n> --- a/git-add--interactive.perl\n> +++ b/git-add--interactive.perl\n> @@ -537,7 +537,7 @@ sub list_and_choose {\n>  \t\t\t\t$last_lf = 1;\n>  \t\t\t}\n>  \t\t}\n> -\t\tif (!$last_lf) {\n> +\t\tif (@stuff && !$last_lf) {\n>  \t\t\tprint \"\\n\";\n>  \t\t}\n>  \n> @@ -634,7 +634,6 @@ sub prompt_help_cmd {\n>  sub status_cmd {\n>  \tlist_and_choose({ LIST_ONLY => 1, HEADER => $status_head },\n>  \t\t\tlist_modified());\n> -\tprint \"\\n\";\n>  }\n>  \n>  sub say_n_paths {\n> @@ -667,7 +666,6 @@ sub update_cmd {\n>  \t\t       map { $_->{VALUE} } @update);\n>  \t\tsay_n_paths('updated', @update);\n>  \t}\n> -\tprint \"\\n\";\n>  }\n>  \n>  sub revert_cmd {\n> @@ -701,7 +699,6 @@ sub revert_cmd {\n>  \t\trefresh();\n>  \t\tsay_n_paths('reverted', @update);\n>  \t}\n> -\tprint \"\\n\";\n>  }\n>  \n>  sub add_untracked_cmd {\n> @@ -711,9 +708,8 @@ sub add_untracked_cmd {\n>  \t\tsystem(qw(git update-index --add --), @add);\n>  \t\tsay_n_paths('added', @add);\n>  \t} else {\n> -\t\tprint __(\"No untracked files.\\n\");\n> +\t\tprint __(\"No untracked file chosen.\\n\");\n>  \t}\n> -\tprint \"\\n\";\n>  }\n>  \n>  sub run_git_apply {\n"},{"id":"322297","messageId":"1497509403.2394.1.camel@gmail.com","threadId":"46159","inReplyTo":"1497445448.2678.1.camel@gmail.com","subject":"Re: Small issue with \"add untracked\" option of 'git add -i'","fromName":"Kaartic Sivaraam","fromEmail":"kaarticsivaraam91196@gmail.com","sentAt":"2017-06-15T06:50:03Z","receivedAt":"2017-06-15T06:50:30Z","isPatch":false,"sender":{"key":"kaartic.sivaraam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12448084?v=4"},"body":"On Wed, 2017-06-14 at 18:34 +0530, Kaartic Sivaraam wrote:\n> That's right. Though I'm not sure of the implementation, I guess the\n> following patch would make `git add -i` do what I thought it should.\n> \nA possible, probably better,  alternative would be to make the empty\nstate output more interactive. i.e., making all the options of `git add\n-i` to output some useful message (something similar to the one printed\nby the `add untracked` option currently.\n\n-- \nRegards,\nKaartic Sivaraam <kaarticsivaraam91196@gmail.com>\n"},{"id":"322798","messageId":"1498013726.5419.1.camel@gmail.com","threadId":"46159","inReplyTo":"xmqqshj5nl3o.fsf@gitster.mtv.corp.google.com","subject":"Re: Small issue with \"add untracked\" option of 'git add -i'","fromName":"Kaartic Sivaraam","fromEmail":"kaarticsivaraam91196@gmail.com","sentAt":"2017-06-21T02:55:26Z","receivedAt":"2017-06-21T02:55:43Z","isPatch":false,"sender":{"key":"kaartic.sivaraam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12448084?v=4"},"body":"On Mon, 2017-06-12 at 10:59 -0700, Junio C Hamano wrote:\n> Together with your other wishes, perhaps something like this is what\n> you have in mind.  The original tried to throw in a blank line as a\n> separator to help interactive users to more easily tell the boundary\n> of blocks of text, but it wasn't consistently doing so (e.g. \"update\"\n> when nothing is dirty was very silent, while \"status\" gave one blank\n> line that is supposed to be shown after the list of changed ones even\n> when the list is empty).\n> \n>  git-add--interactive.perl | 8 ++------\n>  1 file changed, 2 insertions(+), 6 deletions(-)\n> \n> diff --git a/git-add--interactive.perl b/git-add--interactive.perl\n> index 709a5f6ce6..0ec09361b4 100755\n> --- a/git-add--interactive.perl\n> +++ b/git-add--interactive.perl\n> @@ -537,7 +537,7 @@ sub list_and_choose {\n>  \t\t\t\t$last_lf = 1;\n>  \t\t\t}\n>  \t\t}\n> -\t\tif (!$last_lf) {\n> +\t\tif (@stuff && !$last_lf) {\n>  \t\t\tprint \"\\n\";\n>  \t\t}\n>  \n> @@ -634,7 +634,6 @@ sub prompt_help_cmd {\n>  sub status_cmd {\n>  \tlist_and_choose({ LIST_ONLY => 1, HEADER => $status_head },\n>  \t\t\tlist_modified());\n> -\tprint \"\\n\";\n>  }\n>  \n>  sub say_n_paths {\n> @@ -667,7 +666,6 @@ sub update_cmd {\n>  \t\t       map { $_->{VALUE} } @update);\n>  \t\tsay_n_paths('updated', @update);\n>  \t}\n> -\tprint \"\\n\";\n>  }\n>  \n>  sub revert_cmd {\n> @@ -701,7 +699,6 @@ sub revert_cmd {\n>  \t\trefresh();\n>  \t\tsay_n_paths('reverted', @update);\n>  \t}\n> -\tprint \"\\n\";\n>  }\n>  \n>  sub add_untracked_cmd {\n> @@ -711,9 +708,8 @@ sub add_untracked_cmd {\n>  \t\tsystem(qw(git update-index --add --), @add);\n>  \t\tsay_n_paths('added', @add);\n>  \t} else {\n> -\t\tprint __(\"No untracked files.\\n\");\n> +\t\tprint __(\"No untracked file chosen.\\n\");\n>  \t}\n> -\tprint \"\\n\";\n>  }\n>  \n>  sub run_git_apply {\n\nI tried applying the patch and building it locally. For some reason I\ncouldn't see the change in effect. What could I be missing?\n\n-- \nRegards,\nKaartic Sivaraam <kaarticsivaraam91196@gmail.com>\n"},{"id":"322801","messageId":"20170621045211.GA30634@alpha.vpn.ikke.info","threadId":"46159","inReplyTo":"1498013726.5419.1.camel@gmail.com","subject":"Re: Small issue with \"add untracked\" option of 'git add -i'","fromName":"Kevin Daudt","fromEmail":"me@ikke.info","sentAt":"2017-06-21T04:52:11Z","receivedAt":"2017-06-21T04:52:17Z","isPatch":false,"sender":{"key":"me@ikke.info","avatar":"https://avatars.githubusercontent.com/u/135698?v=4"},"body":"On Wed, Jun 21, 2017 at 08:25:26AM +0530, Kaartic Sivaraam wrote:\n> \n> I tried applying the patch and building it locally. For some reason I\n> couldn't see the change in effect. What could I be missing?\n> \n\nDid you make sure you used the git you built, and also the relevant\nsubcommands?\n\nWhat does `which git` and git --exec-path return?\n\nIf you did not install git, but try to run it in the compiled dir, you\ncan better run bin-wrappers/git, which will make sure the correct sub\ncommands are run.\n"},{"id":"322804","messageId":"1498046746.1746.1.camel@gmail.com","threadId":"46159","inReplyTo":"20170621045211.GA30634@alpha.vpn.ikke.info","subject":"Re: Small issue with \"add untracked\" option of 'git add -i'","fromName":"Kaartic Sivaraam","fromEmail":"kaarticsivaraam91196@gmail.com","sentAt":"2017-06-21T12:05:46Z","receivedAt":"2017-06-21T12:06:02Z","isPatch":false,"sender":{"key":"kaartic.sivaraam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12448084?v=4"},"body":"On Wed, 2017-06-21 at 06:52 +0200, Kevin Daudt wrote:\n> Did you make sure you used the git you built, and also the relevant\n> subcommands?\n> \nYou got it. I apologise for any confusion caused here. I seemed to have\naccidentally given a build location in my custom build script,\ndifferent from the one that I assumed. I didn't identify it all along\nas there was a previous build in the assumed location. Anyways, thanks\nfor pointing that out.\n\n> What does `which git` and git --exec-path return?\n> \n> If you did not install git, but try to run it in the compiled dir,\n> you\n> can better run bin-wrappers/git, which will make sure the correct sub\n> commands are run.\n\n"},{"id":"322912","messageId":"1498101195.1687.4.camel@gmail.com","threadId":"46159","inReplyTo":"xmqqshj5nl3o.fsf@gitster.mtv.corp.google.com","subject":"Re: Small issue with \"add untracked\" option of 'git add -i'","fromName":"Kaartic Sivaraam","fromEmail":"kaarticsivaraam91196@gmail.com","sentAt":"2017-06-22T03:13:15Z","receivedAt":"2017-06-22T03:13:31Z","isPatch":false,"sender":{"key":"kaartic.sivaraam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12448084?v=4"},"body":"\nOn Mon, 2017-06-12 at 10:59 -0700, Junio C Hamano wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n> > After prompting to get the list of desired files, if the user chose\n> > nothing, the message is shown.  \"No untracked files chosen.\" is\n> > probably what the code wants to say, I would think.\n> \n> \n> Together with your other wishes, perhaps something like this is what\n> you have in mind.  The original tried to throw in a blank line as a\n> separator to help interactive users to more easily tell the boundary\n> of blocks of text, but it wasn't consistently doing so (e.g. \"update\"\n> when nothing is dirty was very silent, while \"status\" gave one blank\n> line that is supposed to be shown after the list of changed ones even\n> when the list is empty).\n> \n>  git-add--interactive.perl | 8 ++------\n>  1 file changed, 2 insertions(+), 6 deletions(-)\n> \n> diff --git a/git-add--interactive.perl b/git-add--interactive.perl\n> index 709a5f6ce6..0ec09361b4 100755\n> --- a/git-add--interactive.perl\n> +++ b/git-add--interactive.perl\n> @@ -537,7 +537,7 @@ sub list_and_choose {\n>  \t\t\t\t$last_lf = 1;\n>  \t\t\t}\n>  \t\t}\n> -\t\tif (!$last_lf) {\n> +\t\tif (@stuff && !$last_lf) {\n>  \t\t\tprint \"\\n\";\n>  \t\t}\n>  \n> @@ -634,7 +634,6 @@ sub prompt_help_cmd {\n>  sub status_cmd {\n>  \tlist_and_choose({ LIST_ONLY => 1, HEADER => $status_head },\n>  \t\t\tlist_modified());\n> -\tprint \"\\n\";\n>  }\n>  \n>  sub say_n_paths {\n> @@ -667,7 +666,6 @@ sub update_cmd {\n>  \t\t       map { $_->{VALUE} } @update);\n>  \t\tsay_n_paths('updated', @update);\n>  \t}\n> -\tprint \"\\n\";\n>  }\n>  \n>  sub revert_cmd {\n> @@ -701,7 +699,6 @@ sub revert_cmd {\n>  \t\trefresh();\n>  \t\tsay_n_paths('reverted', @update);\n>  \t}\n> -\tprint \"\\n\";\n>  }\n>  \n>  sub add_untracked_cmd {\n> @@ -711,9 +708,8 @@ sub add_untracked_cmd {\n>  \t\tsystem(qw(git update-index --add --), @add);\n>  \t\tsay_n_paths('added', @add);\n>  \t} else {\n> -\t\tprint __(\"No untracked files.\\n\");\n> +\t\tprint __(\"No untracked file chosen.\\n\");\nI guess I should take take back the following statement from my\nprevious thread,\n\n> That does seem to be a more apt message to be shown. It's\n> unambiguous.\n\nThe ambiguity persists. It seems that 'Add untracked' is not\ndifferentiating between 'absence of untracked files' and 'not selecting\nany untracked files' currently. It seems to be the root cause of the\nambiguity.\n\nAs a result the new message \"No untracked file chosen.\" seems absurd\nwhen user tries to choose the '4: add untracked' option in 'git add -i'\nand there are no untracked files in his repository.\n\n    $ git add -i\n\n    *** Commands ***\n      1: status    \t      2: update    \t      3: revert    \t      4: add untracked\n      5: patch    \t      6: diff    \t      7: quit    \t      8: help\n    What now> 4\n    No untracked file chosen.\n\n\n>  \t}\n> -\tprint \"\\n\";\n>  }\n>  \n>  sub run_git_apply {\n\n"}]}