optimise initialized check
Avoid running external command if annex.version is set.
This commit is contained in:
parent
228a724d1d
commit
b7a4ff1c31
4 changed files with 21 additions and 23 deletions
20
Init.hs
20
Init.hs
|
@ -6,8 +6,8 @@
|
|||
-}
|
||||
|
||||
module Init (
|
||||
ensureInitialized,
|
||||
initialize,
|
||||
initializeSafe,
|
||||
uninitialize
|
||||
) where
|
||||
|
||||
|
@ -38,16 +38,20 @@ uninitialize = do
|
|||
g <- Annex.gitRepo
|
||||
gitPreCommitHookUnWrite g
|
||||
|
||||
{- Call to automatically initialize if there is already a git-annex
|
||||
{- Will automatically initialize if there is already a git-annex
|
||||
branch from somewhere. Otherwise, require a manual init
|
||||
to avoid git-annex accidentially being run in git
|
||||
repos that did not intend to use it. -}
|
||||
initializeSafe :: Annex ()
|
||||
initializeSafe = do
|
||||
annexed <- Branch.hasSomeBranch
|
||||
if annexed
|
||||
then initialize
|
||||
else error "First run: git-annex init"
|
||||
ensureInitialized :: Annex ()
|
||||
ensureInitialized = do
|
||||
v <- getVersion
|
||||
case v of
|
||||
Just version -> checkVersion version
|
||||
Nothing -> do
|
||||
annexed <- Branch.hasSomeBranch
|
||||
if annexed
|
||||
then initialize
|
||||
else error "First run: git-annex init"
|
||||
|
||||
{- set up a git pre-commit hook, if one is not already present -}
|
||||
gitPreCommitHookWrite :: Git.Repo -> Annex ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue