refactor and check for a detached HEAD
This commit is contained in:
parent
8a33573caf
commit
a2ec2d3760
2 changed files with 11 additions and 6 deletions
|
@ -22,7 +22,6 @@ import qualified Git
|
||||||
import qualified Types.Remote
|
import qualified Types.Remote
|
||||||
import qualified Remote.Git
|
import qualified Remote.Git
|
||||||
|
|
||||||
import qualified Data.ByteString.Lazy.Char8 as L
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
|
@ -32,7 +31,7 @@ def = [command "sync" (paramOptional (paramRepeating paramRemote))
|
||||||
-- syncing involves several operations, any of which can independently fail
|
-- syncing involves several operations, any of which can independently fail
|
||||||
seek :: CommandSeek
|
seek :: CommandSeek
|
||||||
seek rs = do
|
seek rs = do
|
||||||
!branch <- currentBranch
|
!branch <- fromMaybe nobranch <$> inRepo (Git.Branch.current)
|
||||||
remotes <- syncRemotes rs
|
remotes <- syncRemotes rs
|
||||||
return $ concat $
|
return $ concat $
|
||||||
[ [ commit ]
|
[ [ commit ]
|
||||||
|
@ -42,6 +41,8 @@ seek rs = do
|
||||||
, [ pushLocal branch ]
|
, [ pushLocal branch ]
|
||||||
, [ pushRemote remote branch | remote <- remotes ]
|
, [ pushRemote remote branch | remote <- remotes ]
|
||||||
]
|
]
|
||||||
|
where
|
||||||
|
nobranch = error "no branch is checked out"
|
||||||
|
|
||||||
syncBranch :: Git.Ref -> Git.Ref
|
syncBranch :: Git.Ref -> Git.Ref
|
||||||
syncBranch = Git.Ref.under "refs/heads/synced/"
|
syncBranch = Git.Ref.under "refs/heads/synced/"
|
||||||
|
@ -148,10 +149,6 @@ mergeAnnex = do
|
||||||
Annex.Branch.forceUpdate
|
Annex.Branch.forceUpdate
|
||||||
stop
|
stop
|
||||||
|
|
||||||
currentBranch :: Annex Git.Ref
|
|
||||||
currentBranch = Git.Ref . firstLine . L.unpack <$>
|
|
||||||
inRepo (Git.Command.pipeRead [Param "symbolic-ref", Param "HEAD"])
|
|
||||||
|
|
||||||
mergeFrom :: Git.Ref -> CommandCleanup
|
mergeFrom :: Git.Ref -> CommandCleanup
|
||||||
mergeFrom branch = do
|
mergeFrom branch = do
|
||||||
showOutput
|
showOutput
|
||||||
|
|
|
@ -14,6 +14,14 @@ import Git
|
||||||
import Git.Sha
|
import Git.Sha
|
||||||
import Git.Command
|
import Git.Command
|
||||||
|
|
||||||
|
{- The currently checked out branch. -}
|
||||||
|
current :: Repo -> IO (Maybe Git.Ref)
|
||||||
|
current r = parse <$> pipeRead [Param "symbolic-ref", Param "HEAD"] r
|
||||||
|
where
|
||||||
|
parse v
|
||||||
|
| L.null v = Nothing
|
||||||
|
| otherwise = Just $ Git.Ref $ firstLine $ L.unpack v
|
||||||
|
|
||||||
{- Checks if the second branch has any commits not present on the first
|
{- Checks if the second branch has any commits not present on the first
|
||||||
- branch. -}
|
- branch. -}
|
||||||
changed :: Branch -> Branch -> Repo -> IO Bool
|
changed :: Branch -> Branch -> Repo -> IO Bool
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue