summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-03-04 17:45:11 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-03-04 19:35:55 -0400
commit34eb9b2fdc036e1dab4008751e88b312315928d1 (patch)
tree16ac8a3091a86f49f8c43b1486032f571a3d183e /Command
parenta59665ca42c4215f0f1a66f0bbcc9618fa0e53e7 (diff)
sync: Automatically resolve merge conflict between and annexed file and a regular git file.
This is a new feature, it was not handled before, since it's a bit of an edge case. However, it can be handled exactly the same as a file/dir conflict, just leave the non-annexed item alone. While implementing this, the core resolveMerge' function got a lot simpler and clearer. Note especially that where before there was an asymetric call to stagefromdirectmergedir, now graftin is called symmetrically in both cases. And, in order to add that `graftin us`, the current branch needed to be known (if there is no current branch, there cannot be a merge conflict). This led to some cleanups of how autoMergeFrom behaved when there is no current branch. This commit was sponsored by Philippe Gauthier.
Diffstat (limited to 'Command')
-rw-r--r--Command/Sync.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs
index bd0e57904..07006ef28 100644
--- a/Command/Sync.hs
+++ b/Command/Sync.hs
@@ -169,7 +169,7 @@ mergeLocal (Just branch) = go =<< needmerge
go False = stop
go True = do
showStart "merge" $ Git.Ref.describe syncbranch
- next $ next $ autoMergeFrom syncbranch
+ next $ next $ autoMergeFrom syncbranch (Just branch)
pushLocal :: Maybe Git.Ref -> CommandStart
pushLocal Nothing = stop
@@ -213,10 +213,11 @@ mergeRemote :: Remote -> Maybe Git.Ref -> CommandCleanup
mergeRemote remote b = case b of
Nothing -> do
branch <- inRepo Git.Branch.currentUnsafe
- and <$> mapM merge (branchlist branch)
- Just _ -> and <$> (mapM merge =<< tomerge (branchlist b))
+ and <$> mapM (merge Nothing) (branchlist branch)
+ Just thisbranch ->
+ and <$> (mapM (merge (Just thisbranch)) =<< tomerge (branchlist b))
where
- merge = autoMergeFrom . remoteBranch remote
+ merge thisbranch = flip autoMergeFrom thisbranch . remoteBranch remote
tomerge = filterM (changed remote)
branchlist Nothing = []
branchlist (Just branch) = [branch, syncBranch branch]