{"thread":{"id":"27255","subject":"Filemode is a nuisance","startedAt":"2011-05-04T23:38:03Z","lastAt":"2011-07-22T19:11:46Z","messageCount":4,"participants":["Rowan Lewis","Randal L. Schwartz","Neal Kreitzinger"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"167057","messageId":"5B76586FBEB246BDA2F097E21C78E881@rowanlewis.com","threadId":"27255","inReplyTo":null,"subject":"Filemode is a nuisance","fromName":"Rowan Lewis","fromEmail":"me@rowanlewis.com","sentAt":"2011-05-04T23:38:03Z","receivedAt":"2011-05-04T23:38:03Z","isPatch":false,"sender":{"key":"me@rowanlewis.com","avatar":null},"body":"Hi,\n\nI work at a web development company, a few years ago we switched from using SVN to using git. Since then a lot of little issues and improvements have been made to git, I have to thank the developers for their hard work.\n\nHowever, one problem still remains. Our projects are often cloned onto a large variety of computer environments, from Linux servers to OSX and Windows desktops. Each of these environments tends to have its own requirements for file permissions, depending on how Apache and PHP have been configured.\n\nAs a result of this we're nearly constantly forced to manually set filemode to false in every repository, including submodules.\n\nThe following is the output of git status on one of our repositories with a moderate number of submodules:\n\n# modified:  extensions/asdc (modified content)\n# modified:  extensions/canofspam (modified content, untracked content)\n# modified:  extensions/db_sync (modified content)\n# modified:  extensions/debugdevkit (modified content)\n# modified:  extensions/emailtemplatefilter (modified content)\n# modified:  extensions/export_entry (modified content)\n# modified:  extensions/expressionfield (modified content)\n# modified:  extensions/flexdatefield (modified content)\n# modified:  extensions/globalresourceloader (modified content)\n# modified:  extensions/logsdevkit (modified content)\n# modified:  extensions/mpm/extension.driver.php\n# modified:  extensions/order_entries (modified content)\n# modified:  extensions/profiledevkit (modified content)\n# modified:  extensions/publishfiltering (modified content)\n# modified:  extensions/reflectionfield (modified content)\n# modified:  extensions/selectbox_link_field (modified content)\n# modified:  extensions/subsectionfield (modified content)\n\n>From this list it would appear that each of the 17 items in the extensions directory has been changed, but this is not truly the case. What actually happened was someone running chmod to give Apache access to the files.\n\nIt's a real problem, as I cannot tell which of the submodules actually has changes that I need to deal with. I'm also sure that there's probably some script-foo that I could to do automatically change filemode to false; but unfortunately my bash isn't so great, and I'm the most knowledgable in shell scripting at work.\n\nI see three possible solutions to our woes:\n\n1) It is/becomes possible to disable filemode when repositories are created; so only in the rare case that we need this feature would we have to change the git configuration.\n2) Submodules defere the filemode preference to the parent repository; so that it only needs to be disabled once per project/repository.\n3) I'm an idiot and all of my googling has failed to turn up an obvious/easy solution, and someone here points me to it.\n\nAnyhow, thanks for listening, this email has been a long time coming.\n\nThanks,\nRowan Lewis\n"},{"id":"167066","messageId":"86k4e5al4s.fsf@red.stonehenge.com","threadId":"27255","inReplyTo":"5B76586FBEB246BDA2F097E21C78E881@rowanlewis.com","subject":"Re: Filemode is a nuisance","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2011-05-05T03:20:35Z","receivedAt":"2011-05-05T03:20:35Z","isPatch":false,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":">>>>> \"Rowan\" == Rowan Lewis <me@rowanlewis.com> writes:\n\nRowan> However, one problem still remains. Our projects are often cloned\nRowan> onto a large variety of computer environments, from Linux servers\nRowan> to OSX and Windows desktops.\n\nAnd then installed, how?\n\ngit-clone is *not* meant as a deployment tool.  It is meant to create\nwork dirs for editing and committing.\n\nIf you want to deploy, write the proper deploy tool that sets the permissions.\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nSmalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.\nSee http://methodsandmessages.posterous.com/ for Smalltalk discussion\n"},{"id":"167067","messageId":"54F344CF18124A8D8D1D3DE5E4484736@rowanlewis.com","threadId":"27255","inReplyTo":"86k4e5al4s.fsf@red.stonehenge.com","subject":"Re: Filemode is a nuisance","fromName":"Rowan Lewis","fromEmail":"me@rowanlewis.com","sentAt":"2011-05-05T03:41:28Z","receivedAt":"2011-05-05T03:41:28Z","isPatch":false,"sender":{"key":"me@rowanlewis.com","avatar":null},"body":"If you want to deploy, write the proper deploy tool that sets the permissions.\nIt would be nice to; but unfortunately I cannot, and it would only solve the case where we deploy to the production server.\n\nNot being able to disable filemode will still be a nuisance a lot of the \n"},{"id":"171855","messageId":"4E29CB72.6020904@gmail.com","threadId":"27255","inReplyTo":"5B76586FBEB246BDA2F097E21C78E881@rowanlewis.com","subject":"Re: Filemode is a nuisance","fromName":"Neal Kreitzinger","fromEmail":"nkreitzinger@gmail.com","sentAt":"2011-07-22T19:11:46Z","receivedAt":"2011-07-22T19:11:46Z","isPatch":false,"sender":{"key":"nkreitzinger@gmail.com","avatar":null},"body":"On 5/4/2011 6:38 PM, Rowan Lewis wrote:\n> Hi,\n>\n> I work at a web development company, a few years ago we switched from using SVN to using git. Since then a lot of little issues and improvements have been made to git, I have to thank the developers for their hard work.\n>\n> However, one problem still remains. Our projects are often cloned onto a large variety of computer environments, from Linux servers to OSX and Windows desktops. Each of these environments tends to have its own requirements for file permissions, depending on how Apache and PHP have been configured.\n>\n> As a result of this we're nearly constantly forced to manually set filemode to false in every repository, including submodules.\n>\n> The following is the output of git status on one of our repositories with a moderate number of submodules:\n>\n> # modified:  extensions/asdc (modified content)\n> # modified:  extensions/canofspam (modified content, untracked content)\n> # modified:  extensions/db_sync (modified content)\n> # modified:  extensions/debugdevkit (modified content)\n> # modified:  extensions/emailtemplatefilter (modified content)\n> # modified:  extensions/export_entry (modified content)\n> # modified:  extensions/expressionfield (modified content)\n> # modified:  extensions/flexdatefield (modified content)\n> # modified:  extensions/globalresourceloader (modified content)\n> # modified:  extensions/logsdevkit (modified content)\n> # modified:  extensions/mpm/extension.driver.php\n> # modified:  extensions/order_entries (modified content)\n> # modified:  extensions/profiledevkit (modified content)\n> # modified:  extensions/publishfiltering (modified content)\n> # modified:  extensions/reflectionfield (modified content)\n> # modified:  extensions/selectbox_link_field (modified content)\n> # modified:  extensions/subsectionfield (modified content)\n>\n>  From this list it would appear that each of the 17 items in the extensions directory has been changed, but this is not truly the case. What actually happened was someone running chmod to give Apache access to the files.\n>\n> It's a real problem, as I cannot tell which of the submodules actually has changes that I need to deal with. I'm also sure that there's probably some script-foo that I could to do automatically change filemode to false; but unfortunately my bash isn't so great, and I'm the most knowledgable in shell scripting at work.\n>\n> I see three possible solutions to our woes:\n>\n> 1) It is/becomes possible to disable filemode when repositories are created; so only in the rare case that we need this feature would we have to change the git configuration.\n> 2) Submodules defere the filemode preference to the parent repository; so that it only needs to be disabled once per project/repository.\n> 3) I'm an idiot and all of my googling has failed to turn up an obvious/easy solution, and someone here points me to it.\n>\n> Anyhow, thanks for listening, this email has been a long time coming.\n>\nHere are some puzzle pieces that may help you solve your puzzle. (I'm \nassuming your canonical repository is on Linux.) Git does not track all \npermissions, just whether a file is executable or not.  So in linux a \nfile is stored in git, ie. the object store, as either 777 (executable) \nor 666 (non-executable).  Upon checkout, the permissions are modified by \nthe umask.  Umask can only take away permissons, not add them.  So if \nyou ensure all your files are committed with full permissions \n(executable) then you can modify the checkout to do whatever you want \nwith the umask.  Therefore, the changes you're seeing in git status are \nnot really saying that permissions changed in general, but specifically \nsaying that the permissions changed from not having any executable bits \nat all to having at least one executable bit, or from having at least \none executable bit to not having any executable bits at all.  See this \nthread for more context and information: \nhttp://article.gmane.org/gmane.comp.version-control.git/177583\n(Although, the git-archive aspect may not apply to you, the git \npermissions and umask aspects do.)  With this info, I was able to do \nwhat I needed to do with permissions while keeping filemode=true.\n\nI am not an expert on git permissions, umask, and apache, but in my \nscenario (of linux only) I was able to get these to work together and \navoid unnecessary scripting by getting a better understanding of them. \nMy (non-expert) understanding is that apache only needs to read files in \norder to execute them.  It looks like apache may need to write some of \nyour stuff, also. (In my scenario it does need to write to the files.) \nEither way, you shouldn't care about executable bits on files for apache \naccess, correct?  Of course dirs need to be executable so they can be \ntraversed, but I'm guessing they should probably be set correctly in \nyour object store and post-checkout worktree already by default without \nyou having to script to change it.  IOW, maybe your permissions fixing \nscripts are doing overkill by modding executable bits that don't really \nneed to be modified in order to accomplish your apache access.  Just my \nthoughts based on limited (but successful) scenarios, knowledge, and \nexperience.  (Maybe I'm missing something here.)\n\nv/r,\nneal\n"}]}