resolvemerge: New plumbing command that runs the automatic merge conflict resolver.
This commit is contained in:
parent
003ebf58f5
commit
cb66ca3a76
6 changed files with 60 additions and 3 deletions
38
Command/ResolveMerge.hs
Normal file
38
Command/ResolveMerge.hs
Normal file
|
@ -0,0 +1,38 @@
|
|||
{- git-annex command
|
||||
-
|
||||
- Copyright 2014 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Command.ResolveMerge where
|
||||
|
||||
import Common.Annex
|
||||
import Command
|
||||
import qualified Git
|
||||
import Git.Sha
|
||||
import qualified Git.Branch
|
||||
import Annex.AutoMerge
|
||||
|
||||
def :: [Command]
|
||||
def = [command "resolvemerge" paramNothing seek SectionPlumbing
|
||||
"resolve merge conflicts"]
|
||||
|
||||
seek :: CommandSeek
|
||||
seek ps = withNothing start ps
|
||||
|
||||
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)
|
||||
( next $ next $ return True
|
||||
, 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"
|
Loading…
Add table
Add a link
Reference in a new issue