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
|
2018-10-01 18:12:06 +00:00
|
|
|
seek = withNothing (commandAction start)
|
2014-07-11 20:45:18 +00:00
|
|
|
|
|
|
|
start :: CommandStart
|
|
|
|
start = do
|
2017-11-28 18:40:26 +00:00
|
|
|
showStart' "resolvemerge" Nothing
|
2014-07-11 20:45:18 +00:00
|
|
|
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)
|
2016-04-06 21:32:04 +00:00
|
|
|
ifM (resolveMerge (Just us) them False)
|
2014-07-11 20:59:49 +00:00
|
|
|
( do
|
|
|
|
void $ commitResolvedMerge Git.Branch.ManualCommit
|
|
|
|
next $ next $ return True
|
2016-11-16 01:29:54 +00:00
|
|
|
, giveup "Merge conflict could not be automatically resolved."
|
2014-07-11 20:45:18 +00:00
|
|
|
)
|
|
|
|
where
|
2016-11-16 01:29:54 +00:00
|
|
|
nobranch = giveup "No branch is currently checked out."
|
|
|
|
nomergehead = giveup "No SHA found in .git/merge_head"
|