summaryrefslogtreecommitdiff
path: root/Command/Sync.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-12-31 02:45:12 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-12-31 02:45:12 -0400
commit2998340abb6bd4f9c79ef0079f914955f73f5177 (patch)
treed423c61bd831784c81342ea9216b1e44a976b857 /Command/Sync.hs
parent9a7a77488e3a02c5c834b3880e48a48fe3ea160c (diff)
really fix check that remote needs merged
Diffstat (limited to 'Command/Sync.hs')
-rw-r--r--Command/Sync.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs
index 29211be92..2a836ce98 100644
--- a/Command/Sync.hs
+++ b/Command/Sync.hs
@@ -122,15 +122,17 @@ pullRemote remote branch = do
- were committed, while the synced/master may have changes that some
- other remote synced to this remote. So, merge them both. -}
mergeRemote :: Remote.Remote Annex -> Git.Ref -> CommandCleanup
-mergeRemote remote branch = all id <$> mapM go [branch, syncBranch branch]
+mergeRemote remote branch = all id <$> (mapM merge =<< tomerge)
where
- go b = do
- c <- inRepo $ Git.Branch.changed b (remotebranch b)
- if c
- then mergeFrom $ remotebranch b
- else return True
remotebranch = Git.Ref.under $
"refs/remotes/" ++ Remote.name remote
+ merge = mergeFrom . remotebranch
+ tomerge = filterM changed [branch, syncBranch branch]
+ changed b = do
+ e <- inRepo $ Git.Ref.exists $ remotebranch b
+ if e
+ then inRepo $ Git.Branch.changed b $ remotebranch b
+ else return False
pushRemote :: Remote.Remote Annex -> Git.Ref -> CommandStart
pushRemote remote branch = go =<< needpush