2014-07-11 20:45:18 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2014 Joey Hess <id@joeyh.name>
|
2014-07-11 20:45:18 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.ResolveMerge where
|
|
|
|
|
|
|
|
import Command
|
|
|
|
import qualified Git
|
|
|
|
import Git.Sha
|
|
|
|
import qualified Git.Branch
|
|
|
|
import Annex.AutoMerge
|
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
cmd :: Command
|
2015-07-08 19:08:02 +00:00
|
|
|
cmd = command "resolvemerge" SectionPlumbing
|
2015-07-08 16:33:27 +00:00
|
|
|
"resolve merge conflicts"
|
2015-07-08 19:08:02 +00:00
|
|
|
paramNothing (withParams seek)
|
2014-07-11 20:45:18 +00:00
|
|
|
|
2015-07-08 19:08:02 +00:00
|
|
|
seek :: CmdParams -> CommandSeek
|
2014-10-09 19:35:19 +00:00
|
|
|
seek = withNothing start
|
2014-07-11 20:45:18 +00:00
|
|
|
|
|
|
|
start :: CommandStart
|
|
|
|
start = do
|
|
|
|
showStart "resolvemerge" ""
|
|
|
|
us <- fromMaybe nobranch <$> inRepo Git.Branch.current
|
|
|
|
d <- fromRepo Git.localGitDir
|
|
|
|
let merge_head = d </> "MERGE_HEAD"
|
|
|
|
them <- fromMaybe (error nomergehead) . extractSha
|
|
|
|
<$> liftIO (readFile merge_head)
|
|
|
|
ifM (resolveMerge (Just us) them)
|
2014-07-11 20:59:49 +00:00
|
|
|
( do
|
|
|
|
void $ commitResolvedMerge Git.Branch.ManualCommit
|
|
|
|
next $ next $ return True
|
2014-07-11 20:45:18 +00:00
|
|
|
, error "Merge conflict could not be automatically resolved."
|
|
|
|
)
|
|
|
|
where
|
|
|
|
nobranch = error "No branch is currently checked out."
|
|
|
|
nomergehead = error "No SHA found in .git/merge_head"
|