fix crashes when run in a git repo that has been initted but has no master branch yet

This commit is contained in:
Joey Hess 2012-08-05 15:45:47 -04:00
parent 7478872a09
commit 34fc0d358e
4 changed files with 36 additions and 27 deletions

View file

@ -6,8 +6,6 @@
- Licensed under the GNU GPL version 3 or higher.
-}
{-# LANGUAGE BangPatterns #-}
module Command.Sync where
import Common.Annex
@ -39,7 +37,7 @@ def = [command "sync" (paramOptional (paramRepeating paramRemote))
-- syncing involves several operations, any of which can independently fail
seek :: CommandSeek
seek rs = do
branch <- currentBranch
branch <- fromMaybe nobranch <$> inRepo Git.Branch.current
remotes <- syncRemotes rs
return $ concat
[ [ commit ]
@ -49,11 +47,6 @@ seek rs = do
, [ pushLocal branch ]
, [ pushRemote remote branch | remote <- remotes ]
]
currentBranch :: Annex Git.Ref
currentBranch = do
!branch <- fromMaybe nobranch <$> inRepo Git.Branch.current
return branch
where
nobranch = error "no branch is checked out"