{"thread":{"id":"26233","subject":"'git add' option to non-interactively stage working tree changes","startedAt":"2011-01-07T18:56:48Z","lastAt":"2011-01-07T23:50:38Z","messageCount":5,"participants":["Hrvoje Nikšić","Andreas Schwab","Junio C Hamano","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"159137","messageId":"AANLkTimLKZnVn8Lr-E-8M8T5mXA55XabCT5rC+broeFJ@mail.gmail.com","threadId":"26233","inReplyTo":null,"subject":"'git add' option to non-interactively stage working tree changes","fromName":"Hrvoje Nikšić","fromEmail":"hniksic@gmail.com","sentAt":"2011-01-07T18:56:48Z","receivedAt":"2011-01-07T18:56:48Z","isPatch":false,"sender":{"key":"hniksic@gmail.com","avatar":"https://gravatar.com/avatar/a48579783560f9745ebcec8d2545f4f346ebad7a7dd58455536fc3263cfcea0a?d=mp&s=160"},"body":"Is there a way to non-interactively instruct git to stage all changes\nin the working tree, specifically those that would be detected by \"git\nadd -p\" or \"git commit -a\"?\n\nOne can use \"git add\" for this purpose, but it is necessary to specify\nthe root, and with the unpleasant side effect of adding untracked\nfiles. \"git add -u\" avoids the file addition, but root still has to be\nspelled out. \"git add -p\" does exactly the right thing, but requires\ninteraction. I would like an automated --yes-to-all version of \"git\nadd -p\".\n\nSpecifying the root may seem innocuous, but it is inconsistent with\n\"git diff\" and \"git commit [-a]\", which don't care where in the tree\nyou are.\n"},{"id":"159146","messageId":"m2aajcbiei.fsf@igel.home","threadId":"26233","inReplyTo":"AANLkTimLKZnVn8Lr-E-8M8T5mXA55XabCT5rC+broeFJ@mail.gmail.com","subject":"Re: 'git add' option to non-interactively stage working tree changes","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2011-01-07T19:52:53Z","receivedAt":"2011-01-07T19:52:53Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Hrvoje Nikšić <hniksic@gmail.com> writes:\n\n> Specifying the root may seem innocuous, but it is inconsistent with\n> \"git diff\" and \"git commit [-a]\", which don't care where in the tree\n> you are.\n\nYou can always use \"$(git rev-parse --show-cdup).\" as the root.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"159148","messageId":"AANLkTi=iwOGv3PzrRcVGDwwoTXmJ4CuC11vuYsjn4xxV@mail.gmail.com","threadId":"26233","inReplyTo":"m2aajcbiei.fsf@igel.home","subject":"Re: 'git add' option to non-interactively stage working tree changes","fromName":"Hrvoje Nikšić","fromEmail":"hniksic@gmail.com","sentAt":"2011-01-07T20:03:21Z","receivedAt":"2011-01-07T20:03:21Z","isPatch":false,"sender":{"key":"hniksic@gmail.com","avatar":"https://gravatar.com/avatar/a48579783560f9745ebcec8d2545f4f346ebad7a7dd58455536fc3263cfcea0a?d=mp&s=160"},"body":"On Fri, Jan 7, 2011 at 8:52 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:\n> Hrvoje Nikšić <hniksic@gmail.com> writes:\n>\n>> Specifying the root may seem innocuous, but it is inconsistent with\n>> \"git diff\" and \"git commit [-a]\", which don't care where in the tree\n>> you are.\n>\n> You can always use \"$(git rev-parse --show-cdup).\" as the root.\n\nThanks for the tip. I'll note that this is not exactly easy to\ndiscover, though, and it's quite some typing. Since git add -p and git\nadd -i seem capable of determining the root themselves, maybe there\nshould be a way to do the same for -u? Or even make it the default?\n"},{"id":"159154","messageId":"7vfwt45tqv.fsf@alter.siamese.dyndns.org","threadId":"26233","inReplyTo":"AANLkTi=iwOGv3PzrRcVGDwwoTXmJ4CuC11vuYsjn4xxV@mail.gmail.com","subject":"Re: 'git add' option to non-interactively stage working tree changes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-01-07T20:44:24Z","receivedAt":"2011-01-07T20:44:24Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Hrvoje Nikšić <hniksic@gmail.com> writes:\n\n> Thanks for the tip. I'll note that this is not exactly easy to\n> discover, though, and it's quite some typing. Since git add -p and git\n> add -i seem capable of determining the root themselves, maybe there\n> should be a way to do the same for -u? Or even make it the default?\n\nThe general design principle when talking about an operation to build\ntowards the next commit is to limit the operation to the current working\ndirectory when working from a subdirectory, so I would have to say that\nwhat -p and -i do is wrong, but this is already a very well established\nbehaviour and there is no way to change the default (the same thing can be\nsaid for what -u does).\n\nI think it might be Ok to introduce a --full-tree option to \"git add\" (and\n\"git grep\"), though.  But introduction of corresponding configuration\nvariable to flip the default needs to be done carefully in steps across\nmajor version boundaries as usual (i.e. first introduce --no-full-tree,\nwait for 9 to 12 months to make sure scripts are updated, then start\nhonoring add.fullTree and grep.fullTree configuration variables).\n"},{"id":"159184","messageId":"m3pqs8b7fj.fsf@localhost.localdomain","threadId":"26233","inReplyTo":"7vfwt45tqv.fsf@alter.siamese.dyndns.org","subject":"Re: 'git add' option to non-interactively stage working tree changes","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-01-07T23:50:38Z","receivedAt":"2011-01-07T23:50:38Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> I think it might be Ok to introduce a --full-tree option to \"git add\" (and\n> \"git grep\"), though.  But introduction of corresponding configuration\n> variable to flip the default needs to be done carefully in steps across\n> major version boundaries as usual (i.e. first introduce --no-full-tree,\n\nYou meant --relative[1] here (instead of --no-full-tree), didn't you?\n\n[1] Supported by diff, and in a way by git-diff-tree\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"}]}