summaryrefslogtreecommitdiff
path: root/Command/Sync.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-09-13 14:55:55 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-09-13 14:55:55 -0400
commit8c04e2d27186584e34ea76ff48f4859623654c23 (patch)
treeb3b9833e00ac212e0ee4083dafc852b38de9e5b5 /Command/Sync.hs
parentd8f1761b54ef430560d7e8debf10e7310dfd158b (diff)
sync: Don't fail if the directory it is run in gets removed by the sync.
Diffstat (limited to 'Command/Sync.hs')
-rw-r--r--Command/Sync.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs
index e7da229a0..ca823c736 100644
--- a/Command/Sync.hs
+++ b/Command/Sync.hs
@@ -39,6 +39,7 @@ def = [command "sync" (paramOptional (paramRepeating paramRemote))
-- syncing involves several operations, any of which can independently fail
seek :: CommandSeek
seek rs = do
+ prepMerge
branch <- fromMaybe nobranch <$> inRepo Git.Branch.current
remotes <- syncRemotes rs
return $ concat
@@ -52,6 +53,11 @@ seek rs = do
where
nobranch = error "no branch is checked out"
+{- Merging may delete the current directory, so go to the top
+ - of the repo. -}
+prepMerge :: Annex ()
+prepMerge = liftIO . setCurrentDirectory =<< fromRepo Git.repoPath
+
syncBranch :: Git.Ref -> Git.Ref
syncBranch = Git.Ref.under "refs/heads/synced/"