All of lore.kernel.org
 help / color / mirror / Atom feed
* git repo corruption
@ 2011-01-04  9:10 Levend Sayar
  2011-01-04 12:34 ` Drew Northup
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Levend Sayar @ 2011-01-04  9:10 UTC (permalink / raw)
  To: git

Hi, all.

We have a repo on a corporate server. The sysadmin changed access
rights of files on our repo by accedant.
Some directories have 2750 acces rights before, but he changed as

chmod -R 2770 *

Now when you make git status, every file that is tracked by git is said as

changed but not updated

So is there a way to get this back to normal ?

TIA

_lvnd_
(^_^)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git repo corruption
  2011-01-04  9:10 git repo corruption Levend Sayar
@ 2011-01-04 12:34 ` Drew Northup
  2011-01-04 21:42 ` Neal Kreitzinger
  2011-01-05 18:33 ` Neal Kreitzinger
  2 siblings, 0 replies; 6+ messages in thread
From: Drew Northup @ 2011-01-04 12:34 UTC (permalink / raw)
  To: Levend Sayar; +Cc: git


On Tue, 2011-01-04 at 11:10 +0200, Levend Sayar wrote:
> Hi, all.
> 
> We have a repo on a corporate server. The sysadmin changed access
> rights of files on our repo by accedant.
> Some directories have 2750 acces rights before, but he changed as
> 
> chmod -R 2770 *
> 
> Now when you make git status, every file that is tracked by git is said as
> 
> changed but not updated
> 
> So is there a way to get this back to normal ?
> 
> TIA
> 
> _lvnd_
> (^_^)

Am I correct in guessing that this is not a bare repo?

-- 
-Drew Northup N1XIM
   AKA RvnPhnx on OPN
________________________________________________
"As opposed to vegetable or mineral error?"
-John Pescatore, SANS NewsBites Vol. 12 Num. 59

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git repo corruption
  2011-01-04  9:10 git repo corruption Levend Sayar
  2011-01-04 12:34 ` Drew Northup
@ 2011-01-04 21:42 ` Neal Kreitzinger
  2011-01-05 18:33 ` Neal Kreitzinger
  2 siblings, 0 replies; 6+ messages in thread
From: Neal Kreitzinger @ 2011-01-04 21:42 UTC (permalink / raw)
  To: Levend Sayar; +Cc: git

On 1/4/2011 3:10 AM, Levend Sayar wrote:
> Hi, all.
>
> We have a repo on a corporate server. The sysadmin changed access
> rights of files on our repo by accedant.
> Some directories have 2750 acces rights before, but he changed as
>
> chmod -R 2770 *
>
> Now when you make git status, every file that is tracked by git is said as
>
> changed but not updated
>
> So is there a way to get this back to normal ?
>
> TIA
>
> _lvnd_
> (^_^)

I assume the correct permissions for your tracked files should be 2750? 
  If so, then here's what I would do:

1.  First make a copy of your repo and test these steps on the copy:

e.g.  bare repo:  cp -rvp repo.git repocopy.git
non-bare-repo:  cp -rvp worktree worktreecopy

2. Then cd to the parent of the objects dir in you git repo:

e.g.  bare repo:  cd repocopy.git
non-bare repo:  cd worktreecopy/.git

3.  Then change the permissions of your objects dir:

chmod -R 2750 objects

4.  Validate the results.  Your permissions should match again.

5.  If it worked, then do it on the real repo.


v/r,
Neal

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git repo corruption
  2011-01-04  9:10 git repo corruption Levend Sayar
  2011-01-04 12:34 ` Drew Northup
  2011-01-04 21:42 ` Neal Kreitzinger
@ 2011-01-05 18:33 ` Neal Kreitzinger
  2011-01-05 18:58   ` Levend Sayar
  2 siblings, 1 reply; 6+ messages in thread
From: Neal Kreitzinger @ 2011-01-05 18:33 UTC (permalink / raw)
  To: git; +Cc: git

On 1/4/2011 3:10 AM, Levend Sayar wrote:
> Hi, all.
>
> We have a repo on a corporate server. The sysadmin changed access
> rights of files on our repo by accedant.
> Some directories have 2750 acces rights before, but he changed as
>
> chmod -R 2770 *
>
> Now when you make git status, every file that is tracked by git is said as
>
> changed but not updated
>
> So is there a way to get this back to normal ?
>
> TIA
>
> _lvnd_
> (^_^)

If you want to reset the permissions back to exactly what git would do, 
here is the way I did it after hours one night to fix the repo at our 
shop (modify the permissions value to what you want):

Here is the technique I devised to change permissions on a git repo.  I
needed to lock down a repo so only the integration manager has write 
access.
This method ensures that git sets the permissions according to gits rules.
Please let me know if you know of an easier/better way to do this.

Change Permissions on an Existing Git Repo:

Check System for Users who may be using the Repo:
# w  (see who's logged in)
# ps -A |grep git-menu-scriptname  (where scriptname is some unique string
in the name of the main script your users use to access that repo, if
applicable)
# skill -KILL pts/99  (where 99 = the pts/# from w command, log the user
off)

Change Shared=group to Shared=0644  (change group read+write to group read
only):
Create Template for permissions:
login as fsngit0
$ cd /path/to/template
$ cat config
[core]
         sharedRepository = 0644

Clone repo to set permissions via git:
$ cd /path/to/repo-parent-dir
$ git clone --bare --template=/path/to/template file:///path/to/REPO.git
REPOMOD.git

Compare old and new versions:
$ diff -r REPO.git REPOMOD.git
Only in REPO.git: branches  (empty, keep the old version)
diff -r REPO.git/config REPOMOD.git/config  (merge the old and new together)
1a2
 >       sharedrepository = 0644
6,7c7
<         denyDeletes = true
<         denyNonFastForwards = true
---
 >       denyNonFastforwards = true
Only in REPO.git: description  (keep the old version)
Only in REPO.git: gitk.cache  (gitk will recreate this)
Only in REPO.git: hooks  (contains sample scripts only or whatever scripts
your using, keep the old version)
Only in REPO.git: info  (keep the old version: contains attributes, 
exclude,
or whatever you've setup)
Only in REPO.git/objects: aa (keep new version, loose object have been
packed)
Only in REPO.git/objects/pack:
pack-A5735e9b894dce1498ec1c776dcabc97fd8ceAfc.idx
diff -r REPO.git/packed-refs REPOMOD.git/packed-refs  (keep the new version
because fresh clone has been optimized)
2c2
< Xa8b7b8c8fd3920b89770f2e8356f4ecb71a58cX refs/heads/master
---
 > Ya69744e46276a37932d5f0755a53f76cdf83e0dY refs/heads/master
Only in REPO.git/refs/heads: master  (old version not needed because fresh
clone has been optimized)

Copy over REPO.git files that the clone didn't replicate, but that you need
in order to retain all settings:
$ cp -rv /path/to/REPO.git/info .
repeat as needed...

change permissions to g-w or whatever your core.sharedRepository new value
is supposed to be:
$ chmod -R g-w info
repeat as needed...

Validate your changes:
$ diff -r REPO.git REPOMOD.git
diff -r REPO.git/config REPOMOD.git/config
1a2
 >       sharedrepository = 0644
7c8
<         denyNonFastForwards = true
---
 >       denyNonFastforwards = true
Only in REPO.git: gitk.cache
Only in REPO.git/objects: aa
Only in REPO.git/objects/pack:
pack-A5735e9b894dce1498ec1c776dcabc97fd8ceAfc.idx
diff -r REPO.git/packed-refs REPOMOD.git/packed-refs
2c2
< Xa8b7b8c8fd3920b89770f2e8356f4ecb71a58cX refs/heads/master
---
 > Y69744e46276a37932d5f0755a53f76cdf83e0dY refs/heads/master
Only in REPO.git/refs/heads: master

Backup REPO.git and rename REPOMOD.git to REPO.git:
$ cp -rvp REPO.git REPO.git-old
$ diff -r REPO.git REPO.git-old
$ rm -rf REPO.git
$ cp -rvp REPOMOD.git REPO.git
$ diff -r REPO.git REPOMOD.git
$ diff -r REPO.git REPO.git-old

v/r,
Neal

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git repo corruption
  2011-01-05 18:33 ` Neal Kreitzinger
@ 2011-01-05 18:58   ` Levend Sayar
  2011-01-05 19:49     ` Jakub Narebski
  0 siblings, 1 reply; 6+ messages in thread
From: Levend Sayar @ 2011-01-05 18:58 UTC (permalink / raw)
  To: Neal Kreitzinger; +Cc: git

In fact, let me summarize what I did.

After sysadmin changed permissions, git status gave

Changed but not updated:

modified: bla bla
modified: bla bla
modified: ....

That modifed files are all the files that tracked in fact. So many
files. And git diff gave

diff bla bla
old mode 644
new mode 750

for all files. So only permissions are changed. To revert back I did only

git ls-files -m | xargs git checkout --

And everything is fine.


_lvnd_
(^_^)



On Wed, Jan 5, 2011 at 8:33 PM, Neal Kreitzinger <nkreitzinger@gmail.com> wrote:
> On 1/4/2011 3:10 AM, Levend Sayar wrote:
>>
>> Hi, all.
>>
>> We have a repo on a corporate server. The sysadmin changed access
>> rights of files on our repo by accedant.
>> Some directories have 2750 acces rights before, but he changed as
>>
>> chmod -R 2770 *
>>
>> Now when you make git status, every file that is tracked by git is said as
>>
>> changed but not updated
>>
>> So is there a way to get this back to normal ?
>>
>> TIA
>>
>> _lvnd_
>> (^_^)
>
> If you want to reset the permissions back to exactly what git would do, here
> is the way I did it after hours one night to fix the repo at our shop
> (modify the permissions value to what you want):
>
> Here is the technique I devised to change permissions on a git repo.  I
> needed to lock down a repo so only the integration manager has write access.
> This method ensures that git sets the permissions according to gits rules.
> Please let me know if you know of an easier/better way to do this.
>
> Change Permissions on an Existing Git Repo:
>
> Check System for Users who may be using the Repo:
> # w  (see who's logged in)
> # ps -A |grep git-menu-scriptname  (where scriptname is some unique string
> in the name of the main script your users use to access that repo, if
> applicable)
> # skill -KILL pts/99  (where 99 = the pts/# from w command, log the user
> off)
>
> Change Shared=group to Shared=0644  (change group read+write to group read
> only):
> Create Template for permissions:
> login as fsngit0
> $ cd /path/to/template
> $ cat config
> [core]
>        sharedRepository = 0644
>
> Clone repo to set permissions via git:
> $ cd /path/to/repo-parent-dir
> $ git clone --bare --template=/path/to/template file:///path/to/REPO.git
> REPOMOD.git
>
> Compare old and new versions:
> $ diff -r REPO.git REPOMOD.git
> Only in REPO.git: branches  (empty, keep the old version)
> diff -r REPO.git/config REPOMOD.git/config  (merge the old and new together)
> 1a2
>>       sharedrepository = 0644
> 6,7c7
> <         denyDeletes = true
> <         denyNonFastForwards = true
> ---
>>       denyNonFastforwards = true
> Only in REPO.git: description  (keep the old version)
> Only in REPO.git: gitk.cache  (gitk will recreate this)
> Only in REPO.git: hooks  (contains sample scripts only or whatever scripts
> your using, keep the old version)
> Only in REPO.git: info  (keep the old version: contains attributes, exclude,
> or whatever you've setup)
> Only in REPO.git/objects: aa (keep new version, loose object have been
> packed)
> Only in REPO.git/objects/pack:
> pack-A5735e9b894dce1498ec1c776dcabc97fd8ceAfc.idx
> diff -r REPO.git/packed-refs REPOMOD.git/packed-refs  (keep the new version
> because fresh clone has been optimized)
> 2c2
> < Xa8b7b8c8fd3920b89770f2e8356f4ecb71a58cX refs/heads/master
> ---
>> Ya69744e46276a37932d5f0755a53f76cdf83e0dY refs/heads/master
> Only in REPO.git/refs/heads: master  (old version not needed because fresh
> clone has been optimized)
>
> Copy over REPO.git files that the clone didn't replicate, but that you need
> in order to retain all settings:
> $ cp -rv /path/to/REPO.git/info .
> repeat as needed...
>
> change permissions to g-w or whatever your core.sharedRepository new value
> is supposed to be:
> $ chmod -R g-w info
> repeat as needed...
>
> Validate your changes:
> $ diff -r REPO.git REPOMOD.git
> diff -r REPO.git/config REPOMOD.git/config
> 1a2
>>       sharedrepository = 0644
> 7c8
> <         denyNonFastForwards = true
> ---
>>       denyNonFastforwards = true
> Only in REPO.git: gitk.cache
> Only in REPO.git/objects: aa
> Only in REPO.git/objects/pack:
> pack-A5735e9b894dce1498ec1c776dcabc97fd8ceAfc.idx
> diff -r REPO.git/packed-refs REPOMOD.git/packed-refs
> 2c2
> < Xa8b7b8c8fd3920b89770f2e8356f4ecb71a58cX refs/heads/master
> ---
>> Y69744e46276a37932d5f0755a53f76cdf83e0dY refs/heads/master
> Only in REPO.git/refs/heads: master
>
> Backup REPO.git and rename REPOMOD.git to REPO.git:
> $ cp -rvp REPO.git REPO.git-old
> $ diff -r REPO.git REPO.git-old
> $ rm -rf REPO.git
> $ cp -rvp REPOMOD.git REPO.git
> $ diff -r REPO.git REPOMOD.git
> $ diff -r REPO.git REPO.git-old
>
> v/r,
> Neal
>
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: git repo corruption
  2011-01-05 18:58   ` Levend Sayar
@ 2011-01-05 19:49     ` Jakub Narebski
  0 siblings, 0 replies; 6+ messages in thread
From: Jakub Narebski @ 2011-01-05 19:49 UTC (permalink / raw)
  To: git

Levend Sayar wrote:

> git ls-files -m | xargs git checkout --

Why not simply "git checkout -- ." or "git checkout HEAD -- ."?
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-01-05 19:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-04  9:10 git repo corruption Levend Sayar
2011-01-04 12:34 ` Drew Northup
2011-01-04 21:42 ` Neal Kreitzinger
2011-01-05 18:33 ` Neal Kreitzinger
2011-01-05 18:58   ` Levend Sayar
2011-01-05 19:49     ` Jakub Narebski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.