diff options
-rw-r--r-- | Annex/AutoMerge.hs | 5 | ||||
-rw-r--r-- | CmdLine/GitAnnex.hs | 2 | ||||
-rw-r--r-- | Command/ResolveMerge.hs | 38 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | doc/git-annex.mdwn | 14 | ||||
-rw-r--r-- | doc/todo/Expose_auto-merge_for_manual__44___local_merges.mdwn | 2 |
6 files changed, 60 insertions, 3 deletions
diff --git a/Annex/AutoMerge.hs b/Annex/AutoMerge.hs index d587e03d1..6695c6d38 100644 --- a/Annex/AutoMerge.hs +++ b/Annex/AutoMerge.hs @@ -5,7 +5,10 @@ - Licensed under the GNU GPL version 3 or higher. -} -module Annex.AutoMerge (autoMergeFrom) where +module Annex.AutoMerge + ( autoMergeFrom + , resolveMerge + ) where import Common.Annex import qualified Annex.Queue diff --git a/CmdLine/GitAnnex.hs b/CmdLine/GitAnnex.hs index e4dd29b67..4c9377df9 100644 --- a/CmdLine/GitAnnex.hs +++ b/CmdLine/GitAnnex.hs @@ -54,6 +54,7 @@ import qualified Command.Whereis import qualified Command.List import qualified Command.Log import qualified Command.Merge +import qualified Command.ResolveMerge import qualified Command.Info import qualified Command.Status import qualified Command.Migrate @@ -164,6 +165,7 @@ cmds = concat , Command.List.def , Command.Log.def , Command.Merge.def + , Command.ResolveMerge.def , Command.Info.def , Command.Status.def , Command.Migrate.def diff --git a/Command/ResolveMerge.hs b/Command/ResolveMerge.hs new file mode 100644 index 000000000..b1091e981 --- /dev/null +++ b/Command/ResolveMerge.hs @@ -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" diff --git a/debian/changelog b/debian/changelog index 6aa0fa5f3..39642b575 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,8 @@ git-annex (5.20140710) UNRELEASED; urgency=medium * S3: Deal with AWS ACL configurations that do not allow creating or checking the location of a bucket, but only reading and writing content to it. + * resolvemerge: New plumbing command that runs the automatic merge conflict + resolver. -- Joey Hess <joeyh@debian.org> Wed, 09 Jul 2014 23:29:21 -0400 diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index dc3249456..6dde7c516 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -170,8 +170,8 @@ subdirectories). * `merge` - This performs the same merging that is done by the sync command, but - without pushing or pulling any data. + This performs the same merging (and merge conflict resolution) + that is done by the sync command, but without pushing or pulling any data. One way to use this is to put `git annex merge` into a repository's post-receive hook. Then any syncs to the repository will update its working @@ -939,6 +939,16 @@ subdirectories). Most MATCHING OPTIONS can be used with findref, to limit the files it finds. However, the --include and --exclude options will not work. +* `resolvemerge` + + Resolves a conflicted merge, by adding both conflicting versions of the + file to the tree, using variants of their filename. This is done + automatically when using `git annex sync` or `git annex merge`. + + Note that only merge conflicts that involve an annexed file are resolved. + Merge conflicts between two files that are not annexed will not be + automatically resolved. + * `test` This runs git-annex's built-in test suite. diff --git a/doc/todo/Expose_auto-merge_for_manual__44___local_merges.mdwn b/doc/todo/Expose_auto-merge_for_manual__44___local_merges.mdwn index 0224733c3..c2cf26f83 100644 --- a/doc/todo/Expose_auto-merge_for_manual__44___local_merges.mdwn +++ b/doc/todo/Expose_auto-merge_for_manual__44___local_merges.mdwn @@ -5,3 +5,5 @@ between local branches. E.g., one might invoke «git annex merge» or «git annex autoresolve» after «git merge» when conflicts are found. + +> [[done]] as resolvemerge. --[[Joey]] |