aboutsummaryrefslogtreecommitdiff
path: root/Command/Uninit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-11-08 15:34:10 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-11-08 16:27:20 -0400
commitbf460a0a98d7e4c7f4eac525fcf300629db582b6 (patch)
treebff7cd09529c40fa8cb76fd92428cc41e24ad808 /Command/Uninit.hs
parent2ff8915365099501382183af9855e739fc234861 (diff)
reorder repo parameters last
Many functions took the repo as their first parameter. Changing it consistently to be the last parameter allows doing some useful things with currying, that reduce boilerplate. In particular, g <- gitRepo is almost never needed now, instead use inRepo to run an IO action in the repo, and fromRepo to get a value from the repo. This also provides more opportunities to use monadic and applicative combinators.
Diffstat (limited to 'Command/Uninit.hs')
-rw-r--r--Command/Uninit.hs17
1 files changed, 7 insertions, 10 deletions
diff --git a/Command/Uninit.hs b/Command/Uninit.hs
index 5a6ee0be2..f317b7620 100644
--- a/Command/Uninit.hs
+++ b/Command/Uninit.hs
@@ -28,11 +28,9 @@ check = do
when (b == Annex.Branch.name) $ error $
"cannot uninit when the " ++ b ++ " branch is checked out"
where
- current_branch = do
- g <- gitRepo
- b <- liftIO $
- Git.pipeRead g [Params "rev-parse --abbrev-ref HEAD"]
- return $ head $ lines $ B.unpack b
+ current_branch = head . lines . B.unpack <$> revhead
+ revhead = inRepo $ Git.pipeRead
+ [Params "rev-parse --abbrev-ref HEAD"]
seek :: [CommandSeek]
seek = [withFilesInGit startUnannex, withNothing start]
@@ -53,12 +51,11 @@ perform = next cleanup
cleanup :: CommandCleanup
cleanup = do
- g <- gitRepo
+ annexdir <- fromRepo $ gitAnnexDir
uninitialize
mapM_ removeAnnex =<< getKeysPresent
- liftIO $ removeDirectoryRecursive (gitAnnexDir g)
+ liftIO $ removeDirectoryRecursive annexdir
-- avoid normal shutdown
saveState
- liftIO $ do
- Git.run g "branch" [Param "-D", Param Annex.Branch.name]
- exitSuccess
+ inRepo $ Git.run "branch" [Param "-D", Param Annex.Branch.name]
+ liftIO $ exitSuccess