{"thread":{"id":"43249","subject":"Re: [PATCH] Enter interactive mode if no parameters are given to git-add","startedAt":"2006-12-19T15:16:09Z","lastAt":"2006-12-19T19:04:51Z","messageCount":4,"participants":["Jakub Narebski","Junio C Hamano","Linus Torvalds","Andy Parkins"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"297627","messageId":"200612191516.09606.andyparkins@gmail.com","threadId":"43249","inReplyTo":null,"subject":"[PATCH] Enter interactive mode if no parameters are given to git-add","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-12-19T15:16:09Z","receivedAt":"2006-12-19T15:16:09Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"git-add with no parameters previously adds every modified file.  This\npatch instead makes git-add enter interactive mode.\n\nSigned-off-by: Andy Parkins <andyparkins@gmail.com>\n---\nThis patch is against pu.\n\nIt seemed a bit nasty to add content without explicit instructions to do\nso.  Instead, just drop into interactive mode, which they can easily get out\nof if it was all a big accident, and additionally is quicker than typing\n--interactive.\n\n builtin-add.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-add.c b/builtin-add.c\nindex aa2f0f3..52a63a0 100644\n--- a/builtin-add.c\n+++ b/builtin-add.c\n@@ -96,10 +96,12 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \t\tif (!strcmp(\"--interactive\", argv[i]))\n \t\t\tadd_interactive++;\n \t}\n+\tif (argc == 1)\n+\t\tadd_interactive++;\n \tif (add_interactive) {\n \t\tconst char *args[] = { \"add--interactive\", NULL };\n \n-\t\tif (add_interactive != 1 || argc != 2)\n+\t\tif (add_interactive != 1 || argc > 2)\n \t\t\tdie(\"add --interactive does not take any parameters\");\n \t\texecv_git_cmd(args);\n \t\texit(1);\n-- \n1.4.4.2.g95ee-dirty\n"},{"id":"294133","messageId":"em94l8$n8u$1@sea.gmane.org","threadId":"43249","inReplyTo":"200612191516.09606.andyparkins@gmail.com","subject":"Re: [PATCH] Enter interactive mode if no parameters are given to git-add","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-19T16:42:46Z","receivedAt":"2006-12-19T16:42:46Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"<opublikowany i wysłany>\n\nAndy Parkins wrote:\n\n> gmane.comp.version-control.git\n> git-add with no parameters previously adds every modified file.  This\n> patch instead makes git-add enter interactive mode.\n> \n> Signed-off-by: Andy Parkins <andyparkins@gmail.com>\n> ---\n> This patch is against pu.\n> \n> It seemed a bit nasty to add content without explicit instructions to do\n> so.  Instead, just drop into interactive mode, which they can easily get out\n> of if it was all a big accident, and additionally is quicker than typing\n> --interactive.\n\nHmmm... --interactive is not documented, and neither is --all (erm, I think\ngit add -all oatch was not yet added).\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"},{"id":"295122","messageId":"7vy7p3pxyr.fsf@assigned-by-dhcp.cox.net","threadId":"43249","inReplyTo":"200612191516.09606.andyparkins@gmail.com","subject":"Re: [PATCH] Enter interactive mode if no parameters are given to git-add","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-19T18:00:44Z","receivedAt":"2006-12-19T18:00:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andy Parkins <andyparkins@gmail.com> writes:\n\n> git-add with no parameters previously adds every modified file.  This\n> patch instead makes git-add enter interactive mode.\n> ...\n> It seemed a bit nasty to add content without explicit instructions to do\n> so.\n\nDoes anybody rely on the current behaviour?\n\nIt is nasty and I consider it a bug.  It appears that it has\nbeen like that since the days when it was still a shell script.\n\nWhile I think nobody should drive 'git add' from script, the\nbehaviour to add everything when there is no explicit parameter\n(or fall back to interactive for that matter) has a problem if\nyou say \"some command | xargs git-add --\" (you need \"xargs -r\"\nto fix it, which is GNU).\n\nLet's first have a patch to exit with a warning message (but\nstatus 0) without doing anything when there is no explicit\npaths.\n\nAgain, does anybody rely on the current behaviour?\n\n"},{"id":"296233","messageId":"Pine.LNX.4.64.0612191101490.3483@woody.osdl.org","threadId":"43249","inReplyTo":"7vy7p3pxyr.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Enter interactive mode if no parameters are given to git-add","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-12-19T19:04:51Z","receivedAt":"2006-12-19T19:04:51Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Tue, 19 Dec 2006, Junio C Hamano wrote:\n\n> Andy Parkins <andyparkins@gmail.com> writes:\n> \n> > git-add with no parameters previously adds every modified file.  This\n> > patch instead makes git-add enter interactive mode.\n> > ...\n> > It seemed a bit nasty to add content without explicit instructions to do\n> > so.\n> \n> Does anybody rely on the current behaviour?\n\nI don't know about \"rely\", but yes, it's what I normally do. When I import \na tar-ball, I'll just do\n\n\t..untar..\n\tcd result-x.y.z\n\tgit init-db\n\tgit add\n\tgit commit\n\nand I don't usually use the \".\" at all, since it's unnecessary.\n\nBut hey, if it enters some interactive mode, maybe I can teach myself to \neither just do \"git add .\", or if the interactive mode has a choice of \"a\" \nfor \"all\", then why not?\n\n> While I think nobody should drive 'git add' from script, the\n> behaviour to add everything when there is no explicit parameter\n> (or fall back to interactive for that matter) has a problem if\n> you say \"some command | xargs git-add --\" (you need \"xargs -r\"\n> to fix it, which is GNU).\n\nThat's a really good argument against the current behaviour of \"git add\", \nso while I actually use it without any parameters, I will concur that we \nshould probably change it.\n\n"}]}