summaryrefslogtreecommitdiff
path: root/Command/Sync.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-03-14 17:43:34 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-03-14 17:43:34 -0400
commit60ab3d84e188b8dd3a284d962df25bbee41ff1cb (patch)
tree768d4f632bab0152dbc1ca72f81fc3b9c7915c0a /Command/Sync.hs
parenta4f72c9625486786a4549cf4db1b542ea89da7c7 (diff)
added ifM and nuked 11 lines of code
no behavior changes
Diffstat (limited to 'Command/Sync.hs')
-rw-r--r--Command/Sync.hs30
1 files changed, 13 insertions, 17 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs
index 51b6d6f63..b9ef0bc97 100644
--- a/Command/Sync.hs
+++ b/Command/Sync.hs
@@ -51,11 +51,7 @@ remoteBranch :: Remote -> Git.Ref -> Git.Ref
remoteBranch remote = Git.Ref.under $ "refs/remotes/" ++ Remote.name remote
syncRemotes :: [String] -> Annex [Remote]
-syncRemotes rs = do
- fast <- Annex.getState Annex.fast
- if fast
- then nub <$> pickfast
- else wanted
+syncRemotes rs = ifM (Annex.getState Annex.fast) ( nub <$> pickfast , wanted )
where
pickfast = (++) <$> listed <*> (good =<< fastest <$> available)
wanted
@@ -113,11 +109,11 @@ pullRemote remote branch = do
showStart "pull" (Remote.name remote)
next $ do
showOutput
- fetched <- inRepo $ Git.Command.runBool "fetch"
+ stopUnless fetch $
+ next $ mergeRemote remote branch
+ where
+ fetch = inRepo $ Git.Command.runBool "fetch"
[Param $ Remote.name remote]
- if fetched
- then next $ mergeRemote remote branch
- else stop
{- The remote probably has both a master and a synced/master branch.
- Which to merge from? Well, the master has whatever latest changes
@@ -159,15 +155,15 @@ mergeFrom branch = do
changed :: Remote -> Git.Ref -> Annex Bool
changed remote b = do
let r = remoteBranch remote b
- e <- inRepo $ Git.Ref.exists r
- if e
- then inRepo $ Git.Branch.changed b r
- else return False
+ ifM (inRepo $ Git.Ref.exists r)
+ ( inRepo $ Git.Branch.changed b r
+ , return False
+ )
newer :: Remote -> Git.Ref -> Annex Bool
newer remote b = do
let r = remoteBranch remote b
- e <- inRepo $ Git.Ref.exists r
- if e
- then inRepo $ Git.Branch.changed r b
- else return True
+ ifM (inRepo $ Git.Ref.exists r)
+ ( inRepo $ Git.Branch.changed r b
+ , return True
+ )