fix init reversion when core.sharedRepository = group
authorJoey Hess <joeyh@joeyh.name>
Mon, 12 Jul 2021 14:15:49 +0000 (10:15 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 12 Jul 2021 14:15:49 +0000 (10:15 -0400)
init: Fix misbehavior when core.sharedRepository = group that caused it to
enter an adjusted branch. (Reversion in version 8.20210630)

Commit 4b1b9d7a83f0da71665658e6234e699e182cbddc 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
Annex/Init.hs
Annex/Perms.hs
CHANGELOG
doc/bugs/regression__58___index.lck_in_shared-group_is_not_g+w/comment_3_621beade26a1dbbdea000ca43d93a325._comment [new file with mode: 0644]

index 4209478e9a2277a75920cebba615445b75aedb1e..962eae26eb50c8710d414627a59d79f0490d9ae4 100644 (file)
@@ -25,6 +25,7 @@ import qualified Git
 import qualified Git.Config
 import qualified Git.Objects
 import Git.Types (fromConfigValue)
+import Git.ConfigTypes (SharedRepository(..))
 import qualified Annex.Branch
 import Logs.UUID
 import Logs.Trust.Basic
@@ -243,8 +244,8 @@ isInitialized = maybe Annex.Branch.hasSibling (const $ return True) =<< getVersi
 probeCrippledFileSystem :: Annex Bool
 probeCrippledFileSystem = withEventuallyCleanedOtherTmp $ \tmp -> do
        (r, warnings) <- probeCrippledFileSystem' tmp
-               (Just freezeContent)
-               (Just thawContent)
+               (Just (freezeContent' UnShared))
+               (Just (thawContent' UnShared))
        mapM_ warning warnings
        return r
 
index 4e71b2c78ca9be60a041cb6ce3e59380af7d5baa..733922c5124a542b4bbd145a732213ee3b2a2f74 100644 (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
index 749928397c03736b2fc02ca27a479d53b00e9fb3..28ca0457a50d21a7c99acc0628a486fa776867d6 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,9 @@ git-annex (8.20210631) UNRELEASED; urgency=medium
   * addurl: Avoid crashing when used on beegfs.
   * --debug output goes to stderr again, not stdout.
     (Reversion in version 8.20210428)
+  * init: Fix misbehavior when core.sharedRepository = group that
+    caused it to enter an adjusted branch.
+    (Reversion in version 8.20210630)
 
  -- Joey Hess <id@joeyh.name>  Wed, 30 Jun 2021 17:55:10 -0400
 
diff --git a/doc/bugs/regression__58___index.lck_in_shared-group_is_not_g+w/comment_3_621beade26a1dbbdea000ca43d93a325._comment b/doc/bugs/regression__58___index.lck_in_shared-group_is_not_g+w/comment_3_621beade26a1dbbdea000ca43d93a325._comment
new file mode 100644 (file)
index 0000000..ab42972
--- /dev/null
@@ -0,0 +1,7 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 3"""
+ date="2021-07-12T14:09:19Z"
+ content="""
+(Fixed the problem with git-annex init's probing.)
+"""]]