{"thread":{"id":"12883","subject":"git add -i doesn't update permissions","startedAt":"2008-03-26T10:23:32Z","lastAt":"2008-03-27T16:08:03Z","messageCount":5,"participants":["Jörg Sommer","Jeff King","Wincent Colaiuta","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"73169","messageId":"20080326102332.GA26842@alea.gnuu.de","threadId":"12883","inReplyTo":null,"subject":"git add -i doesn't update permissions","fromName":"Jörg Sommer","fromEmail":"joerg@alea.gnuu.de","sentAt":"2008-03-26T10:23:32Z","receivedAt":"2008-03-26T10:23:32Z","isPatch":false,"sender":{"key":"joerg@alea.gnuu.de","avatar":null},"body":"Hi,\n\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex 77c90f6..424271c 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -66,4 +66,14 @@ test_expect_success 'revert works (commit)' '\n        grep \"unchanged *+3/-0 file\" output\n '\n \n+test_expect_success 'update file permissions' '\n+       git reset --hard &&\n+       chmod +x file &&\n+       printf \"p\\n1\\n\" | git add -i\n+'\n+\n+test_expect_failure \"update file permissions doesn't work\" '\n+       git status\n+'\n+\n test_done\n\nBye, Jörg.\n-- \nUnsere Zweifel sind Verräter und oft genug verspielen wir den möglichen\nGewinn, weil wir den Versuch nicht wagen.\n"},{"id":"73188","messageId":"20080327055746.GA8469@coredump.intra.peff.net","threadId":"12883","inReplyTo":"20080326102332.GA26842@alea.gnuu.de","subject":"Re: git add -i doesn't update permissions","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-03-27T05:57:46Z","receivedAt":"2008-03-27T05:57:46Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 26, 2008 at 11:23:32AM +0100, Jörg Sommer wrote:\n\n> +test_expect_success 'update file permissions' '\n> +       git reset --hard &&\n> +       chmod +x file &&\n> +       printf \"p\\n1\\n\" | git add -i\n> +'\n\nI'm not sure this is really a bug (but rather a feature request, which I\nwill explain below). add--interactive has two modes for moving changes\nto files into the index:\n\n  1. 'u' will 'update' the file in the index, adding the new content and\n     any mode changes\n\n  2. 'p' will show you each patch hunk from the file, which can then\n     either be added or not.\n\nYou are using 'p' and expecting it to work with the file mode, when it\nis purely about picking content hunks.\n\nSo I think the test _should_ be\n\n  printf \"u\\n1\\n\" | git add -i\n\nin which case it works fine.\n\nNow, if you are interested in adding the mode change of a file but _not_\nits content, I think that is a reasonable thing to ask for. And it's\nsomething that is not possible with \"add -i\" right now, I don't think.\nYou seemed to expect that 'p' would present the mode change and say \"do\nyou want to stage this?\" which I think is a reasonable interface. Though\nin that case \"[p]atch\" should perhaps be \"[p]artial update\".\n\n-Peff\n"},{"id":"73189","messageId":"20080327062932.GA11697@coredump.intra.peff.net","threadId":"12883","inReplyTo":"20080327055746.GA8469@coredump.intra.peff.net","subject":"Re: git add -i doesn't update permissions","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-03-27T06:29:32Z","receivedAt":"2008-03-27T06:29:32Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Mar 27, 2008 at 01:57:46AM -0400, Jeff King wrote:\n\n>   2. 'p' will show you each patch hunk from the file, which can then\n>      either be added or not.\n> \n> You are using 'p' and expecting it to work with the file mode, when it\n> is purely about picking content hunks.\n\nActually, it is a little more complex than that. \"git add -p\" will reuse\nthe header from \"git diff\", so it will not apply a mode change _unless_\nany hunk is selected.\n\nSo probably the right behavior is to split the header into \"boilerplate\"\nand \"mode change\", and then ask whether the mode change should be\nincluded.\n\n-Peff\n"},{"id":"73190","messageId":"0F970CFF-EA4A-46D8-BB1D-345C3513B124@wincent.com","threadId":"12883","inReplyTo":"20080327055746.GA8469@coredump.intra.peff.net","subject":"Re: git add -i doesn't update permissions","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2008-03-27T06:32:13Z","receivedAt":"2008-03-27T06:32:13Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 27/3/2008, a las 6:57, Jeff King escribió:\n\n> Now, if you are interested in adding the mode change of a file but  \n> _not_\n> its content, I think that is a reasonable thing to ask for. And it's\n> something that is not possible with \"add -i\" right now, I don't think.\n> You seemed to expect that 'p' would present the mode change and say  \n> \"do\n> you want to stage this?\" which I think is a reasonable interface.  \n> Though\n> in that case \"[p]atch\" should perhaps be \"[p]artial update\".\n\nOr even \"[p]ick\" (changes to be staged), which is a bit shorter.\n\nBut yes, I've always thought that \"[p]atch\" didn't really describe  \nwhat that subcommand really does.\n\nCheers,\nWincent\n"},{"id":"73203","messageId":"7vfxucb15o.fsf@gitster.siamese.dyndns.org","threadId":"12883","inReplyTo":"20080327055746.GA8469@coredump.intra.peff.net","subject":"Re: git add -i doesn't update permissions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-27T16:08:03Z","receivedAt":"2008-03-27T16:08:03Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Now, if you are interested in adding the mode change of a file but _not_\n> its content, I think that is a reasonable thing to ask for. And it's\n> something that is not possible with \"add -i\" right now, I don't think.\n\nIt's worse than that.  It _theoretically_ is possible that this limitation\nbecomes problematic if you are in this situation:\n\n 1. Notice a problem in the gostak script that it should distim doshes but\n    it doesn't.\n\n 2. Start working to change the gostak script.\n\n 3. Notice that the gistak script itself needs the +x bit but it doesn't.\n\n 4. Being a very disciplined person, you want to make sequence of commits\n    that record each separate logical change as a separate commit.  You\n    would want to record \"Add executable bit to the gostak script\" first,\n    and then work further on the contents of the script to make \"Enhance\n    the gostak script to distim doshes\" as two logically separate steps.\n\t\nThis is not something you can do with \"git add\" in general, although I do\nnot see how this can be an issue in real life.\n\nTwo already available solutions are:\n\n (1) git reset HEAD -- gostak ;# undo staged content changes\n     git update-index --chmod=+x gostak\n     git commit -m \"Add executable bit to the gostak script\"\n     edit gostak ;# work more\n     git add gostak\n     git commit -m \"Enhance the gostak script to distim doshes\"\n\n (2) git stash ;# undo changes\n     chmod +x gostak\n     git add gostak\n     git commit -m \"Add executable bit to the gostak script\"\n     git stash pop ;# take the wip changes back\n     edit gostak ;# work more\n     git add gostak\n     git commit -m \"Enhance the gostak script to distim doshes\"\n"}]}