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:
parent
f184dca7de
commit
d4fd966396
4 changed files with 20 additions and 7 deletions
|
@ -9,6 +9,7 @@
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
module Annex.Init (
|
module Annex.Init (
|
||||||
|
checkInitializeAllowed,
|
||||||
ensureInitialized,
|
ensureInitialized,
|
||||||
autoInitialize,
|
autoInitialize,
|
||||||
isInitialized,
|
isInitialized,
|
||||||
|
@ -68,11 +69,13 @@ import qualified System.FilePath.ByteString as P
|
||||||
import Control.Concurrent.Async
|
import Control.Concurrent.Async
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
checkInitializeAllowed :: Annex a -> Annex a
|
data InitializeAllowed = InitializeAllowed
|
||||||
|
|
||||||
|
checkInitializeAllowed :: (InitializeAllowed -> Annex a) -> Annex a
|
||||||
checkInitializeAllowed a = guardSafeToUseRepo $ noAnnexFileContent' >>= \case
|
checkInitializeAllowed a = guardSafeToUseRepo $ noAnnexFileContent' >>= \case
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
checkSqliteWorks
|
checkSqliteWorks
|
||||||
a
|
a InitializeAllowed
|
||||||
Just noannexmsg -> do
|
Just noannexmsg -> do
|
||||||
warning "Initialization prevented by .noannex file (remove the file to override)"
|
warning "Initialization prevented by .noannex file (remove the file to override)"
|
||||||
unless (null noannexmsg) $
|
unless (null noannexmsg) $
|
||||||
|
@ -100,7 +103,7 @@ genDescription Nothing = do
|
||||||
Left _ -> [hostname, ":", reldir]
|
Left _ -> [hostname, ":", reldir]
|
||||||
|
|
||||||
initialize :: Bool -> Maybe String -> Maybe RepoVersion -> Annex ()
|
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
|
{- Has to come before any commits are made as the shared
|
||||||
- clone heuristic expects no local objects. -}
|
- clone heuristic expects no local objects. -}
|
||||||
sharedclone <- checkSharedClone
|
sharedclone <- checkSharedClone
|
||||||
|
@ -110,7 +113,7 @@ initialize autoinit mdescription mversion = checkInitializeAllowed $ do
|
||||||
ensureCommit $ Annex.Branch.create
|
ensureCommit $ Annex.Branch.create
|
||||||
|
|
||||||
prepUUID
|
prepUUID
|
||||||
initialize' autoinit mversion
|
initialize' autoinit mversion initallowed
|
||||||
|
|
||||||
initSharedClone sharedclone
|
initSharedClone sharedclone
|
||||||
|
|
||||||
|
@ -122,8 +125,8 @@ initialize autoinit mdescription mversion = checkInitializeAllowed $ do
|
||||||
|
|
||||||
-- Everything except for uuid setup, shared clone setup, and initial
|
-- Everything except for uuid setup, shared clone setup, and initial
|
||||||
-- description.
|
-- description.
|
||||||
initialize' :: Bool -> Maybe RepoVersion -> Annex ()
|
initialize' :: Bool -> Maybe RepoVersion -> InitializeAllowed -> Annex ()
|
||||||
initialize' autoinit mversion = checkInitializeAllowed $ do
|
initialize' autoinit mversion _initallowed = do
|
||||||
checkLockSupport
|
checkLockSupport
|
||||||
checkFifoSupport
|
checkFifoSupport
|
||||||
checkCrippledFileSystem
|
checkCrippledFileSystem
|
||||||
|
|
|
@ -35,6 +35,6 @@ perform s = do
|
||||||
then return $ toUUID s
|
then return $ toUUID s
|
||||||
else Remote.nameToUUID s
|
else Remote.nameToUUID s
|
||||||
storeUUID u
|
storeUUID u
|
||||||
initialize' False Nothing
|
checkInitializeAllowed $ initialize' False Nothing
|
||||||
Annex.SpecialRemote.autoEnable
|
Annex.SpecialRemote.autoEnable
|
||||||
next $ return True
|
next $ return True
|
||||||
|
|
|
@ -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?
|
anything to be done or should we just raise the bar to 140 in that test?
|
||||||
|
|
||||||
|
[[!tag projects/datalad]]
|
||||||
|
|
|
@ -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..
|
||||||
|
"""]]
|
Loading…
Add table
Add a link
Reference in a new issue