From de8f6959d3cd4af348e7a72c45e6e1d6d3cd4cfa Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 1 Jun 2017 12:46:36 -0400 Subject: configuration to disable automatic merge conflict resolution * Added annex.resolvemerge configuration, which can be set to false to disable the usual automatic merge conflict resolution done by git-annex sync and the assistant. * sync: Added --no-resolvemerge option. Note that disabling merge conflict resolution is probably not a good idea in a direct mode repo or adjusted branch. Since updates to both are done outside the usual work tree, if it fails the tree is not left in a conflicted state, and it would be hard to manually resolve the conflict. Still, made annex.resolvemerge be supported in those cases for consistency. This commit was sponsored by Riku Voipio. --- Annex/AdjustedBranch.hs | 6 +++--- Annex/AutoMerge.hs | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'Annex') diff --git a/Annex/AdjustedBranch.hs b/Annex/AdjustedBranch.hs index c0225540a..52f73e638 100644 --- a/Annex/AdjustedBranch.hs +++ b/Annex/AdjustedBranch.hs @@ -318,8 +318,8 @@ findAdjustingCommit (AdjBranch b) = go =<< catCommit b {- Update the currently checked out adjusted branch, merging the provided - branch into it. Note that the provided branch should be a non-adjusted - branch. -} -updateAdjustedBranch :: Branch -> (OrigBranch, Adjustment) -> [Git.Merge.MergeConfig] -> Git.Branch.CommitMode -> Annex Bool -updateAdjustedBranch tomerge (origbranch, adj) mergeconfig commitmode = catchBoolIO $ +updateAdjustedBranch :: Branch -> (OrigBranch, Adjustment) -> [Git.Merge.MergeConfig] -> Annex Bool -> Git.Branch.CommitMode -> Annex Bool +updateAdjustedBranch tomerge (origbranch, adj) mergeconfig canresolvemerge commitmode = catchBoolIO $ join $ preventCommits go where adjbranch@(AdjBranch currbranch) = originalToAdjusted origbranch adj @@ -417,7 +417,7 @@ updateAdjustedBranch tomerge (origbranch, adj) mergeconfig commitmode = catchBoo -- this commit will be a fast-forward. adjmergecommitff <- commitAdjustedTree' adjtree (BasisBranch mergecommit) [currbranch] showAction "Merging into adjusted branch" - ifM (autoMergeFrom adjmergecommitff (Just currbranch) mergeconfig commitmode) + ifM (autoMergeFrom adjmergecommitff (Just currbranch) mergeconfig canresolvemerge commitmode) ( reparent adjtree adjmergecommit =<< getcurrentcommit , return False ) diff --git a/Annex/AutoMerge.hs b/Annex/AutoMerge.hs index 7f982e515..91f8fc99e 100644 --- a/Annex/AutoMerge.hs +++ b/Annex/AutoMerge.hs @@ -43,18 +43,18 @@ import qualified Data.ByteString.Lazy as L - Callers should use Git.Branch.changed first, to make sure that - there are changes from the current branch to the branch being merged in. -} -autoMergeFrom :: Git.Ref -> Maybe Git.Ref -> [Git.Merge.MergeConfig] -> Git.Branch.CommitMode -> Annex Bool -autoMergeFrom branch currbranch mergeconfig commitmode = do +autoMergeFrom :: Git.Ref -> Maybe Git.Ref -> [Git.Merge.MergeConfig] -> Annex Bool -> Git.Branch.CommitMode -> Annex Bool +autoMergeFrom branch currbranch mergeconfig canresolvemerge commitmode = do showOutput case currbranch of Nothing -> go Nothing Just b -> go =<< inRepo (Git.Ref.sha b) where go old = ifM isDirect - ( mergeDirect currbranch old branch (resolveMerge old branch False) mergeconfig commitmode + ( mergeDirect currbranch old branch resolvemerge mergeconfig commitmode , do r <- inRepo (Git.Merge.merge branch mergeconfig commitmode) - <||> (resolveMerge old branch False <&&> commitResolvedMerge commitmode) + <||> (resolvemerge <&&> commitResolvedMerge commitmode) -- Merging can cause new associated files to appear -- and the smudge filter will add them to the database. -- To ensure that this process sees those changes, @@ -62,6 +62,11 @@ autoMergeFrom branch currbranch mergeconfig commitmode = do Database.Keys.closeDb return r ) + where + resolvemerge = ifM canresolvemerge + ( resolveMerge old branch False + , return False + ) {- Resolves a conflicted merge. It's important that any conflicts be - resolved in a way that itself avoids later merge conflicts, since -- cgit v1.2.3