summaryrefslogtreecommitdiff
path: root/Init.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-08-17 18:38:26 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-08-17 18:38:26 -0400
commitb7a4ff1c3185404d36d34b372b016be052394a95 (patch)
tree28953385279993b63c28007dd0cfa5e3ea5e853a /Init.hs
parent228a724d1d1e1d2f27763bd5f71473acc4d022d9 (diff)
optimise initialized check
Avoid running external command if annex.version is set.
Diffstat (limited to 'Init.hs')
-rw-r--r--Init.hs20
1 files changed, 12 insertions, 8 deletions
diff --git a/Init.hs b/Init.hs
index 36d3ed0fa..ae92998bb 100644
--- a/Init.hs
+++ b/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 ()