summaryrefslogtreecommitdiff
path: root/Command/Unannex.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/Unannex.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/Unannex.hs')
-rw-r--r--Command/Unannex.hs16
1 files changed, 8 insertions, 8 deletions
diff --git a/Command/Unannex.hs b/Command/Unannex.hs
index 825f81939..d24f921a9 100644
--- a/Command/Unannex.hs
+++ b/Command/Unannex.hs
@@ -31,8 +31,8 @@ start file = isAnnexed file $ \(key, _) -> do
then do
force <- Annex.getState Annex.force
unless force $ do
- g <- gitRepo
- staged <- liftIO $ LsFiles.staged g [Git.workTree g]
+ top <- fromRepo Git.workTree
+ staged <- inRepo $ LsFiles.staged [top]
unless (null staged) $
error "This command cannot be run when there are already files staged for commit."
Annex.changeState $ \s -> s { Annex.force = True }
@@ -46,19 +46,19 @@ perform file key = next $ cleanup file key
cleanup :: FilePath -> Key -> CommandCleanup
cleanup file key = do
- g <- gitRepo
-
liftIO $ removeFile file
- liftIO $ Git.run g "rm" [Params "--quiet --", File file]
+ inRepo $ Git.run "rm" [Params "--quiet --", File file]
-- git rm deletes empty directories; put them back
liftIO $ createDirectoryIfMissing True (parentDir file)
fast <- Annex.getState Annex.fast
if fast
- then liftIO $ do
+ then do
-- fast mode: hard link to content in annex
- createLink (gitAnnexLocation g key) file
- allowWrite file
+ src <- fromRepo $ gitAnnexLocation key
+ liftIO $ do
+ createLink src file
+ allowWrite file
else do
fromAnnex key file
logStatus key InfoMissing