summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-12-30 18:19:45 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-12-30 18:19:45 -0400
commit56488e807bcc7dcc6e9f5b3e359ddf4f4fb5d8d1 (patch)
treea875337afbf14f4707c55e62d9e95643266e4ce3 /Command
parentf2fa29bf3bb3d54b9c4d789b36d04ba693dee53a (diff)
check that synced/master exists before trying to use it
and a nice error message if syncing is not set up yet
Diffstat (limited to 'Command')
-rw-r--r--Command/Sync.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs
index 423a772f3..1c20c409c 100644
--- a/Command/Sync.hs
+++ b/Command/Sync.hs
@@ -70,9 +70,13 @@ commit = do
return True
mergeLocal :: Git.Ref -> CommandStart
-mergeLocal branch = go =<< inRepo (Git.Branch.changed branch mergebranch)
+mergeLocal branch = go =<< needmerge
where
mergebranch = Git.Ref.under "refs/heads/synced" branch
+ needmerge = do
+ unlessM (inRepo $ Git.Ref.exists mergebranch) $
+ error $ Git.Ref.describe mergebranch ++ " does not exist; create it to enable sync"
+ inRepo $ Git.Branch.changed branch mergebranch
go False = stop
go True = do
showStart "merge" $ Git.Ref.describe mergebranch
@@ -109,7 +113,8 @@ pullRemote remote branch = do
next $ do
checkRemote remote
showOutput
- fetched <- inRepo $ Git.Command.runBool "fetch" [Param (Remote.name remote)]
+ fetched <- inRepo $ Git.Command.runBool "fetch"
+ [Param $ Remote.name remote]
if fetched
then next $ mergeRemote remote branch
else stop
@@ -123,7 +128,7 @@ pushRemote remote branch syncbranch = go =<< newer
where
newer = inRepo $ Git.Branch.changed syncbranchRemote syncbranch
go False = stop
- go True = do
+ go True = do
showStart "push" (Remote.name remote)
ex <- inRepo $ Git.Ref.exists syncbranchRemote
next $ next $ do