summaryrefslogtreecommitdiff
path: root/Command/Uninit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-10-27 16:31:35 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-10-27 16:31:35 -0400
commit5b74b130a39d8c45e7d24520d838d6c1635582c7 (patch)
tree3d2816f028e7135a168d64c6342e1a2588260417 /Command/Uninit.hs
parent66194684acaf8dc5c72e5a163465b42050cf9212 (diff)
refactored and generalized pre-command sanity checking
Diffstat (limited to 'Command/Uninit.hs')
-rw-r--r--Command/Uninit.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/Command/Uninit.hs b/Command/Uninit.hs
index 8214c4208..60e86cc03 100644
--- a/Command/Uninit.hs
+++ b/Command/Uninit.hs
@@ -19,18 +19,15 @@ import qualified Annex.Branch
import Annex.Content
command :: [Command]
-command = [repoCommand "uninit" paramPaths seek
+command = [Command "uninit" paramPaths check seek
"de-initialize git-annex and clean out repository"]
-seek :: [CommandSeek]
-seek = [withNothing startCheck, withFilesInGit startUnannex, withNothing start]
-
-startCheck :: CommandStart
-startCheck = do
+check :: Annex ()
+check = do
+ needsRepo
b <- current_branch
when (b == Annex.Branch.name) $ error $
"cannot uninit when the " ++ b ++ " branch is checked out"
- stop
where
current_branch = do
g <- gitRepo
@@ -38,6 +35,9 @@ startCheck = do
Git.pipeRead g [Params "rev-parse --abbrev-ref HEAD"]
return $ head $ lines $ B.unpack b
+seek :: [CommandSeek]
+seek = [withFilesInGit startUnannex, withNothing start]
+
startUnannex :: FilePath -> CommandStart
startUnannex file = do
-- Force fast mode before running unannex. This way, if multiple