{"thread":{"id":"26185","subject":"git repo corruption","startedAt":"2011-01-04T09:10:38Z","lastAt":"2011-01-05T19:49:43Z","messageCount":6,"participants":["Levend Sayar","Drew Northup","Neal Kreitzinger","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"158876","messageId":"AANLkTi=TSy1WQZARNQgGfPiV93hQ-xmCTip75JAixgDB@mail.gmail.com","threadId":"26185","inReplyTo":null,"subject":"git repo corruption","fromName":"Levend Sayar","fromEmail":"levendsayar@gmail.com","sentAt":"2011-01-04T09:10:38Z","receivedAt":"2011-01-04T09:10:38Z","isPatch":false,"sender":{"key":"levendsayar@gmail.com","avatar":"https://gravatar.com/avatar/eee5111f431e01d6607dcdce1434e09cd262a451cf27ddab2db11ec0d7197be3?d=mp&s=160"},"body":"Hi, all.\n\nWe have a repo on a corporate server. The sysadmin changed access\nrights of files on our repo by accedant.\nSome directories have 2750 acces rights before, but he changed as\n\nchmod -R 2770 *\n\nNow when you make git status, every file that is tracked by git is said as\n\nchanged but not updated\n\nSo is there a way to get this back to normal ?\n\nTIA\n\n_lvnd_\n(^_^)\n"},{"id":"158882","messageId":"1294144443.17969.0.camel@drew-northup.unet.maine.edu","threadId":"26185","inReplyTo":"AANLkTi=TSy1WQZARNQgGfPiV93hQ-xmCTip75JAixgDB@mail.gmail.com","subject":"Re: git repo corruption","fromName":"Drew Northup","fromEmail":"drew.northup@maine.edu","sentAt":"2011-01-04T12:34:03Z","receivedAt":"2011-01-04T12:34:03Z","isPatch":false,"sender":{"key":"drew.northup@maine.edu","avatar":"https://avatars.githubusercontent.com/u/18331571?v=4"},"body":"\nOn Tue, 2011-01-04 at 11:10 +0200, Levend Sayar wrote:\n> Hi, all.\n> \n> We have a repo on a corporate server. The sysadmin changed access\n> rights of files on our repo by accedant.\n> Some directories have 2750 acces rights before, but he changed as\n> \n> chmod -R 2770 *\n> \n> Now when you make git status, every file that is tracked by git is said as\n> \n> changed but not updated\n> \n> So is there a way to get this back to normal ?\n> \n> TIA\n> \n> _lvnd_\n> (^_^)\n\nAm I correct in guessing that this is not a bare repo?\n\n-- \n-Drew Northup N1XIM\n   AKA RvnPhnx on OPN\n________________________________________________\n\"As opposed to vegetable or mineral error?\"\n-John Pescatore, SANS NewsBites Vol. 12 Num. 59\n"},{"id":"158917","messageId":"4D239450.2010509@gmail.com","threadId":"26185","inReplyTo":"AANLkTi=TSy1WQZARNQgGfPiV93hQ-xmCTip75JAixgDB@mail.gmail.com","subject":"Re: git repo corruption","fromName":"Neal Kreitzinger","fromEmail":"nkreitzinger@gmail.com","sentAt":"2011-01-04T21:42:40Z","receivedAt":"2011-01-04T21:42:40Z","isPatch":false,"sender":{"key":"nkreitzinger@gmail.com","avatar":null},"body":"On 1/4/2011 3:10 AM, Levend Sayar wrote:\n> Hi, all.\n>\n> We have a repo on a corporate server. The sysadmin changed access\n> rights of files on our repo by accedant.\n> Some directories have 2750 acces rights before, but he changed as\n>\n> chmod -R 2770 *\n>\n> Now when you make git status, every file that is tracked by git is said as\n>\n> changed but not updated\n>\n> So is there a way to get this back to normal ?\n>\n> TIA\n>\n> _lvnd_\n> (^_^)\n\nI assume the correct permissions for your tracked files should be 2750? \n  If so, then here's what I would do:\n\n1.  First make a copy of your repo and test these steps on the copy:\n\ne.g.  bare repo:  cp -rvp repo.git repocopy.git\nnon-bare-repo:  cp -rvp worktree worktreecopy\n\n2. Then cd to the parent of the objects dir in you git repo:\n\ne.g.  bare repo:  cd repocopy.git\nnon-bare repo:  cd worktreecopy/.git\n\n3.  Then change the permissions of your objects dir:\n\nchmod -R 2750 objects\n\n4.  Validate the results.  Your permissions should match again.\n\n5.  If it worked, then do it on the real repo.\n\n\nv/r,\nNeal\n"},{"id":"158976","messageId":"4D24B969.50007@gmail.com","threadId":"26185","inReplyTo":"AANLkTi=TSy1WQZARNQgGfPiV93hQ-xmCTip75JAixgDB@mail.gmail.com","subject":"Re: git repo corruption","fromName":"Neal Kreitzinger","fromEmail":"nkreitzinger@gmail.com","sentAt":"2011-01-05T18:33:13Z","receivedAt":"2011-01-05T18:33:13Z","isPatch":false,"sender":{"key":"nkreitzinger@gmail.com","avatar":null},"body":"On 1/4/2011 3:10 AM, Levend Sayar wrote:\n> Hi, all.\n>\n> We have a repo on a corporate server. The sysadmin changed access\n> rights of files on our repo by accedant.\n> Some directories have 2750 acces rights before, but he changed as\n>\n> chmod -R 2770 *\n>\n> Now when you make git status, every file that is tracked by git is said as\n>\n> changed but not updated\n>\n> So is there a way to get this back to normal ?\n>\n> TIA\n>\n> _lvnd_\n> (^_^)\n\nIf you want to reset the permissions back to exactly what git would do, \nhere is the way I did it after hours one night to fix the repo at our \nshop (modify the permissions value to what you want):\n\nHere is the technique I devised to change permissions on a git repo.  I\nneeded to lock down a repo so only the integration manager has write \naccess.\nThis method ensures that git sets the permissions according to gits rules.\nPlease let me know if you know of an easier/better way to do this.\n\nChange Permissions on an Existing Git Repo:\n\nCheck System for Users who may be using the Repo:\n# w  (see who's logged in)\n# ps -A |grep git-menu-scriptname  (where scriptname is some unique string\nin the name of the main script your users use to access that repo, if\napplicable)\n# skill -KILL pts/99  (where 99 = the pts/# from w command, log the user\noff)\n\nChange Shared=group to Shared=0644  (change group read+write to group read\nonly):\nCreate Template for permissions:\nlogin as fsngit0\n$ cd /path/to/template\n$ cat config\n[core]\n         sharedRepository = 0644\n\nClone repo to set permissions via git:\n$ cd /path/to/repo-parent-dir\n$ git clone --bare --template=/path/to/template file:///path/to/REPO.git\nREPOMOD.git\n\nCompare old and new versions:\n$ diff -r REPO.git REPOMOD.git\nOnly in REPO.git: branches  (empty, keep the old version)\ndiff -r REPO.git/config REPOMOD.git/config  (merge the old and new together)\n1a2\n >       sharedrepository = 0644\n6,7c7\n<         denyDeletes = true\n<         denyNonFastForwards = true\n---\n >       denyNonFastforwards = true\nOnly in REPO.git: description  (keep the old version)\nOnly in REPO.git: gitk.cache  (gitk will recreate this)\nOnly in REPO.git: hooks  (contains sample scripts only or whatever scripts\nyour using, keep the old version)\nOnly in REPO.git: info  (keep the old version: contains attributes, \nexclude,\nor whatever you've setup)\nOnly in REPO.git/objects: aa (keep new version, loose object have been\npacked)\nOnly in REPO.git/objects/pack:\npack-A5735e9b894dce1498ec1c776dcabc97fd8ceAfc.idx\ndiff -r REPO.git/packed-refs REPOMOD.git/packed-refs  (keep the new version\nbecause fresh clone has been optimized)\n2c2\n< Xa8b7b8c8fd3920b89770f2e8356f4ecb71a58cX refs/heads/master\n---\n > Ya69744e46276a37932d5f0755a53f76cdf83e0dY refs/heads/master\nOnly in REPO.git/refs/heads: master  (old version not needed because fresh\nclone has been optimized)\n\nCopy over REPO.git files that the clone didn't replicate, but that you need\nin order to retain all settings:\n$ cp -rv /path/to/REPO.git/info .\nrepeat as needed...\n\nchange permissions to g-w or whatever your core.sharedRepository new value\nis supposed to be:\n$ chmod -R g-w info\nrepeat as needed...\n\nValidate your changes:\n$ diff -r REPO.git REPOMOD.git\ndiff -r REPO.git/config REPOMOD.git/config\n1a2\n >       sharedrepository = 0644\n7c8\n<         denyNonFastForwards = true\n---\n >       denyNonFastforwards = true\nOnly in REPO.git: gitk.cache\nOnly in REPO.git/objects: aa\nOnly in REPO.git/objects/pack:\npack-A5735e9b894dce1498ec1c776dcabc97fd8ceAfc.idx\ndiff -r REPO.git/packed-refs REPOMOD.git/packed-refs\n2c2\n< Xa8b7b8c8fd3920b89770f2e8356f4ecb71a58cX refs/heads/master\n---\n > Y69744e46276a37932d5f0755a53f76cdf83e0dY refs/heads/master\nOnly in REPO.git/refs/heads: master\n\nBackup REPO.git and rename REPOMOD.git to REPO.git:\n$ cp -rvp REPO.git REPO.git-old\n$ diff -r REPO.git REPO.git-old\n$ rm -rf REPO.git\n$ cp -rvp REPOMOD.git REPO.git\n$ diff -r REPO.git REPOMOD.git\n$ diff -r REPO.git REPO.git-old\n\nv/r,\nNeal\n"},{"id":"158979","messageId":"AANLkTikxW-kEhCFKBb-rGPM2xZtk7WyomYnFwz_DYV43@mail.gmail.com","threadId":"26185","inReplyTo":"4D24B969.50007@gmail.com","subject":"Re: git repo corruption","fromName":"Levend Sayar","fromEmail":"levendsayar@gmail.com","sentAt":"2011-01-05T18:58:44Z","receivedAt":"2011-01-05T18:58:44Z","isPatch":false,"sender":{"key":"levendsayar@gmail.com","avatar":"https://gravatar.com/avatar/eee5111f431e01d6607dcdce1434e09cd262a451cf27ddab2db11ec0d7197be3?d=mp&s=160"},"body":"In fact, let me summarize what I did.\n\nAfter sysadmin changed permissions, git status gave\n\nChanged but not updated:\n\nmodified: bla bla\nmodified: bla bla\nmodified: ....\n\nThat modifed files are all the files that tracked in fact. So many\nfiles. And git diff gave\n\ndiff bla bla\nold mode 644\nnew mode 750\n\nfor all files. So only permissions are changed. To revert back I did only\n\ngit ls-files -m | xargs git checkout --\n\nAnd everything is fine.\n\n\n_lvnd_\n(^_^)\n\n\n\nOn Wed, Jan 5, 2011 at 8:33 PM, Neal Kreitzinger <nkreitzinger@gmail.com> wrote:\n> On 1/4/2011 3:10 AM, Levend Sayar wrote:\n>>\n>> Hi, all.\n>>\n>> We have a repo on a corporate server. The sysadmin changed access\n>> rights of files on our repo by accedant.\n>> Some directories have 2750 acces rights before, but he changed as\n>>\n>> chmod -R 2770 *\n>>\n>> Now when you make git status, every file that is tracked by git is said as\n>>\n>> changed but not updated\n>>\n>> So is there a way to get this back to normal ?\n>>\n>> TIA\n>>\n>> _lvnd_\n>> (^_^)\n>\n> If you want to reset the permissions back to exactly what git would do, here\n> is the way I did it after hours one night to fix the repo at our shop\n> (modify the permissions value to what you want):\n>\n> Here is the technique I devised to change permissions on a git repo.  I\n> needed to lock down a repo so only the integration manager has write access.\n> This method ensures that git sets the permissions according to gits rules.\n> Please let me know if you know of an easier/better way to do this.\n>\n> Change Permissions on an Existing Git Repo:\n>\n> Check System for Users who may be using the Repo:\n> # w  (see who's logged in)\n> # ps -A |grep git-menu-scriptname  (where scriptname is some unique string\n> in the name of the main script your users use to access that repo, if\n> applicable)\n> # skill -KILL pts/99  (where 99 = the pts/# from w command, log the user\n> off)\n>\n> Change Shared=group to Shared=0644  (change group read+write to group read\n> only):\n> Create Template for permissions:\n> login as fsngit0\n> $ cd /path/to/template\n> $ cat config\n> [core]\n>        sharedRepository = 0644\n>\n> Clone repo to set permissions via git:\n> $ cd /path/to/repo-parent-dir\n> $ git clone --bare --template=/path/to/template file:///path/to/REPO.git\n> REPOMOD.git\n>\n> Compare old and new versions:\n> $ diff -r REPO.git REPOMOD.git\n> Only in REPO.git: branches  (empty, keep the old version)\n> diff -r REPO.git/config REPOMOD.git/config  (merge the old and new together)\n> 1a2\n>>       sharedrepository = 0644\n> 6,7c7\n> <         denyDeletes = true\n> <         denyNonFastForwards = true\n> ---\n>>       denyNonFastforwards = true\n> Only in REPO.git: description  (keep the old version)\n> Only in REPO.git: gitk.cache  (gitk will recreate this)\n> Only in REPO.git: hooks  (contains sample scripts only or whatever scripts\n> your using, keep the old version)\n> Only in REPO.git: info  (keep the old version: contains attributes, exclude,\n> or whatever you've setup)\n> Only in REPO.git/objects: aa (keep new version, loose object have been\n> packed)\n> Only in REPO.git/objects/pack:\n> pack-A5735e9b894dce1498ec1c776dcabc97fd8ceAfc.idx\n> diff -r REPO.git/packed-refs REPOMOD.git/packed-refs  (keep the new version\n> because fresh clone has been optimized)\n> 2c2\n> < Xa8b7b8c8fd3920b89770f2e8356f4ecb71a58cX refs/heads/master\n> ---\n>> Ya69744e46276a37932d5f0755a53f76cdf83e0dY refs/heads/master\n> Only in REPO.git/refs/heads: master  (old version not needed because fresh\n> clone has been optimized)\n>\n> Copy over REPO.git files that the clone didn't replicate, but that you need\n> in order to retain all settings:\n> $ cp -rv /path/to/REPO.git/info .\n> repeat as needed...\n>\n> change permissions to g-w or whatever your core.sharedRepository new value\n> is supposed to be:\n> $ chmod -R g-w info\n> repeat as needed...\n>\n> Validate your changes:\n> $ diff -r REPO.git REPOMOD.git\n> diff -r REPO.git/config REPOMOD.git/config\n> 1a2\n>>       sharedrepository = 0644\n> 7c8\n> <         denyNonFastForwards = true\n> ---\n>>       denyNonFastforwards = true\n> Only in REPO.git: gitk.cache\n> Only in REPO.git/objects: aa\n> Only in REPO.git/objects/pack:\n> pack-A5735e9b894dce1498ec1c776dcabc97fd8ceAfc.idx\n> diff -r REPO.git/packed-refs REPOMOD.git/packed-refs\n> 2c2\n> < Xa8b7b8c8fd3920b89770f2e8356f4ecb71a58cX refs/heads/master\n> ---\n>> Y69744e46276a37932d5f0755a53f76cdf83e0dY refs/heads/master\n> Only in REPO.git/refs/heads: master\n>\n> Backup REPO.git and rename REPOMOD.git to REPO.git:\n> $ cp -rvp REPO.git REPO.git-old\n> $ diff -r REPO.git REPO.git-old\n> $ rm -rf REPO.git\n> $ cp -rvp REPOMOD.git REPO.git\n> $ diff -r REPO.git REPOMOD.git\n> $ diff -r REPO.git REPO.git-old\n>\n> v/r,\n> Neal\n>\n>\n>\n"},{"id":"158983","messageId":"ig2i0m$uv9$1@dough.gmane.org","threadId":"26185","inReplyTo":"AANLkTikxW-kEhCFKBb-rGPM2xZtk7WyomYnFwz_DYV43@mail.gmail.com","subject":"Re: git repo corruption","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-01-05T19:49:43Z","receivedAt":"2011-01-05T19:49:43Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Levend Sayar wrote:\n\n> git ls-files -m | xargs git checkout --\n\nWhy not simply \"git checkout -- .\" or \"git checkout HEAD -- .\"?\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"}]}