aboutsummaryrefslogtreecommitdiff
path: root/Command/Unannex.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-12-09 12:23:45 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-12-09 12:23:45 -0400
commit3f5f28b48754bc91620a6354ca70afe4c61c9894 (patch)
tree6c71b52187f442ce619ffac7c672fc7f0b8f84ce /Command/Unannex.hs
parentd64132a43ae176e8a1353d5463c5387a93da9ad7 (diff)
factor out a stopUnless
code melt for lunch
Diffstat (limited to 'Command/Unannex.hs')
-rw-r--r--Command/Unannex.hs24
1 files changed, 10 insertions, 14 deletions
diff --git a/Command/Unannex.hs b/Command/Unannex.hs
index e97b6d05d..263ff88b4 100644
--- a/Command/Unannex.hs
+++ b/Command/Unannex.hs
@@ -25,21 +25,17 @@ seek = [withFilesInGit $ whenAnnexed start]
{- The unannex subcommand undoes an add. -}
start :: FilePath -> (Key, Backend Annex) -> CommandStart
-start file (key, _) = do
- ishere <- inAnnex key
- if ishere
- then do
- force <- Annex.getState Annex.force
- unless force $ do
- 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 }
+start file (key, _) = stopUnless (inAnnex key) $ do
+ force <- Annex.getState Annex.force
+ unless force $ do
+ 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 }
- showStart "unannex" file
- next $ perform file key
- else stop
+ showStart "unannex" file
+ next $ perform file key
perform :: FilePath -> Key -> CommandPerform
perform file key = next $ cleanup file key