avoid dup check of guardSafeToUseRepo

Speeds up init slightly, and reduces the number of syscalls by the
dynamic linker.

Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
Joey Hess 2022-08-29 13:52:58 -04:00
parent f184dca7de
commit d4fd966396
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 20 additions and 7 deletions

View file

@ -9,6 +9,7 @@
{-# LANGUAGE OverloadedStrings #-}
module Annex.Init (
checkInitializeAllowed,
ensureInitialized,
autoInitialize,
isInitialized,
@ -68,11 +69,13 @@ import qualified System.FilePath.ByteString as P
import Control.Concurrent.Async
#endif
checkInitializeAllowed :: Annex a -> Annex a
data InitializeAllowed = InitializeAllowed
checkInitializeAllowed :: (InitializeAllowed -> Annex a) -> Annex a
checkInitializeAllowed a = guardSafeToUseRepo $ noAnnexFileContent' >>= \case
Nothing -> do
checkSqliteWorks
a
a InitializeAllowed
Just noannexmsg -> do
warning "Initialization prevented by .noannex file (remove the file to override)"
unless (null noannexmsg) $
@ -100,7 +103,7 @@ genDescription Nothing = do
Left _ -> [hostname, ":", reldir]
initialize :: Bool -> Maybe String -> Maybe RepoVersion -> Annex ()
initialize autoinit mdescription mversion = checkInitializeAllowed $ do
initialize autoinit mdescription mversion = checkInitializeAllowed $ \initallowed -> do
{- Has to come before any commits are made as the shared
- clone heuristic expects no local objects. -}
sharedclone <- checkSharedClone
@ -110,7 +113,7 @@ initialize autoinit mdescription mversion = checkInitializeAllowed $ do
ensureCommit $ Annex.Branch.create
prepUUID
initialize' autoinit mversion
initialize' autoinit mversion initallowed
initSharedClone sharedclone
@ -122,8 +125,8 @@ initialize autoinit mdescription mversion = checkInitializeAllowed $ do
-- Everything except for uuid setup, shared clone setup, and initial
-- description.
initialize' :: Bool -> Maybe RepoVersion -> Annex ()
initialize' autoinit mversion = checkInitializeAllowed $ do
initialize' :: Bool -> Maybe RepoVersion -> InitializeAllowed -> Annex ()
initialize' autoinit mversion _initallowed = do
checkLockSupport
checkFifoSupport
checkCrippledFileSystem

View file

@ -35,6 +35,6 @@ perform s = do
then return $ toUUID s
else Remote.nameToUUID s
storeUUID u
initialize' False Nothing
checkInitializeAllowed $ initialize' False Nothing
Annex.SpecialRemote.autoEnable
next $ return True

View file

@ -49,3 +49,5 @@ pr-55/build-ubuntu.yaml-799-32886238-failed/test-annex-more/6_Seek of dynlibs.tx
```
anything to be done or should we just raise the bar to 140 in that test?
[[!tag projects/datalad]]

View file

@ -0,0 +1,8 @@
[[!comment format=mdwn
username="joey"
subject="""comment 2"""
date="2022-08-29T17:51:49Z"
content="""
I was able to eliminate one of the calls to `git config --local --list`
anyway..
"""]]