diff options
-rw-r--r-- | Annex/AutoMerge.hs | 10 | ||||
-rw-r--r-- | CmdLine/GitAnnex.hs | 2 | ||||
-rw-r--r-- | Command/ResolveMerge.hs | 40 | ||||
-rw-r--r-- | Test.hs | 1 | ||||
-rw-r--r-- | debian/changelog | 4 | ||||
-rw-r--r-- | doc/devblog/day_195-196__catching_up.mdwn | 13 | ||||
-rw-r--r-- | doc/git-annex.mdwn | 14 | ||||
-rw-r--r-- | doc/todo/Expose_auto-merge_for_manual__44___local_merges.mdwn | 2 |
8 files changed, 81 insertions, 5 deletions
diff --git a/Annex/AutoMerge.hs b/Annex/AutoMerge.hs index d587e03d1..c19011e2d 100644 --- a/Annex/AutoMerge.hs +++ b/Annex/AutoMerge.hs @@ -5,7 +5,11 @@ - Licensed under the GNU GPL version 3 or higher. -} -module Annex.AutoMerge (autoMergeFrom) where +module Annex.AutoMerge + ( autoMergeFrom + , resolveMerge + , commitResolvedMerge + ) where import Common.Annex import qualified Annex.Queue @@ -174,7 +178,7 @@ resolveMerge' (Just us) them u = do return (Just file) {- git-merge moves conflicting files away to files - - named something like f~HEAD or f~branch, but the + - named something like f~HEAD or f~branch or just f, but the - exact name chosen can vary. Once the conflict is resolved, - this cruft can be deleted. To avoid deleting legitimate - files that look like this, only delete files that are @@ -191,7 +195,7 @@ cleanConflictCruft resolvedfs top = do liftIO $ nukeFile f | otherwise = noop s = S.fromList resolvedfs - matchesresolved f = S.member (base f) s + matchesresolved f = S.member f s || S.member (base f) s base f = reverse $ drop 1 $ dropWhile (/= '~') $ reverse f commitResolvedMerge :: Git.Branch.CommitMode -> Annex Bool 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..a50e2aa9d --- /dev/null +++ b/Command/ResolveMerge.hs @@ -0,0 +1,40 @@ +{- 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) + ( do + void $ commitResolvedMerge Git.Branch.ManualCommit + 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" @@ -857,6 +857,7 @@ test_conflict_resolution testenv = let v = filter (variantprefix `isPrefixOf`) l length v == 2 @? (what ++ " not exactly 2 variant files in: " ++ show l) + conflictor `notElem` l @? ("conflictor still present after conflict resolution") indir testenv d $ do git_annex testenv "get" v @? "get failed" git_annex_expectoutput testenv "find" v v diff --git a/debian/changelog b/debian/changelog index 6aa0fa5f3..0b15e7754 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,10 @@ 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. + * Deal with change in git 2.0 that made indirect mode merge conflict + resolution leave behind old files. -- Joey Hess <joeyh@debian.org> Wed, 09 Jul 2014 23:29:21 -0400 diff --git a/doc/devblog/day_195-196__catching_up.mdwn b/doc/devblog/day_195-196__catching_up.mdwn new file mode 100644 index 000000000..2c04eaa15 --- /dev/null +++ b/doc/devblog/day_195-196__catching_up.mdwn @@ -0,0 +1,13 @@ +Spent past 2 days catching up on backlog and doing bug triage and some +minor bug fixes and features. Backlog is 27, lowest in quite a while so I +feel well on top of things. + +I was saddened to find [this bug](http://git-annex.branchable.com/bugs/files_lost_during_upgrade/#comment-b265c796b1599d2dde649699cb54fa86) +where I almost managed to analize the [[ugy_bug|day_193-194__ugly_bug]]'s race +condition, but not quite (and then went on vacation). BTW, I have not heard +from anyone else who was hit by that bug so far. + +The linux autobuilders are still down; their host server had a disk crash +in an electrical outage. Might be down for a while. I would not mind +setting up a redundant autobuilder if anyone else would like to donate a +linux VM with 4+ gb of ram. 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]] |