fix init reversion when core.sharedRepository = group

init: Fix misbehavior when core.sharedRepository = group that caused it to
enter an adjusted branch. (Reversion in version 8.20210630)

Commit 4b1b9d7a83 made init call
freezeContent in case there was a hook that could prevent writing in
situations where perms don't. But with the above git config, freezeContent
does not prevent write at all. So init needs to do what freezeContent does
with a non-shared git config.

Or init could check for that config, and skip the probing, since it
won't actually be preventing write to any files. But that would make init
too aware if details of Annex.Perms, and also would break if the git config
were changed after init.

Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
Joey Hess 2021-07-12 10:15:49 -04:00
parent 215aee105d
commit 6a581f8b8b
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 25 additions and 5 deletions

View file

@ -15,8 +15,10 @@ module Annex.Perms (
createWorkTreeDirectory,
noUmask,
freezeContent,
freezeContent',
isContentWritePermOk,
thawContent,
thawContent',
createContentDir,
freezeContentDir,
thawContentDir,
@ -131,8 +133,12 @@ createWorkTreeDirectory dir = do
- owned by another user, so failure to set this mode is ignored.
-}
freezeContent :: RawFilePath -> Annex ()
freezeContent file = unlessM crippledFileSystem $ do
withShared go
freezeContent file = unlessM crippledFileSystem $
withShared $ \sr -> freezeContent' sr file
freezeContent' :: SharedRepository -> RawFilePath -> Annex ()
freezeContent' sr file = do
go sr
freezeHook file
where
go GroupShared = liftIO $ void $ tryIO $ modifyFileMode file $
@ -160,7 +166,10 @@ isContentWritePermOk file = ifM crippledFileSystem
{- Allows writing to an annexed file that freezeContent was called on
- before. -}
thawContent :: RawFilePath -> Annex ()
thawContent file = thawPerms (withShared go) (thawHook file)
thawContent file = withShared $ \sr -> thawContent' sr file
thawContent' :: SharedRepository -> RawFilePath -> Annex ()
thawContent' sr file = thawPerms (go sr) (thawHook file)
where
go GroupShared = liftIO $ void $ tryIO $ groupWriteRead file
go AllShared = liftIO $ void $ tryIO $ groupWriteRead file