diff options
author | Joey Hess <joey@kitenet.net> | 2014-06-09 20:10:12 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-06-09 20:10:12 -0400 |
commit | 2ca723a7c1c1130465b21d7db23c137976f58f6f (patch) | |
tree | 15c4e176efd734f26610b03e65eb37313050ca0c /Annex | |
parent | 35b79079e4cdd8534ae8d8868b46b3ad00a8ba64 (diff) |
avoid fast-forwarding when a merge conflict was auto-resolved
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/AutoMerge.hs | 2 | ||||
-rw-r--r-- | Annex/Direct.hs | 23 |
2 files changed, 15 insertions, 10 deletions
diff --git a/Annex/AutoMerge.hs b/Annex/AutoMerge.hs index e6f7e0497..22d3332dd 100644 --- a/Annex/AutoMerge.hs +++ b/Annex/AutoMerge.hs @@ -67,7 +67,7 @@ autoMergeFrom branch currbranch = do - tree. The resolution is committed. - - In direct mode, the work tree is not touched here, and no commit is made; - - files are staged to the index, and written to the gitAnnexMergeDir, and + - files are staged to the index, and written to the gitAnnexMergeDir, and - later mergeDirectCleanup handles updating the work tree. -} resolveMerge :: Maybe Git.Ref -> Git.Ref -> Annex Bool diff --git a/Annex/Direct.hs b/Annex/Direct.hs index 029bc16d7..70188ea11 100644 --- a/Annex/Direct.hs +++ b/Annex/Direct.hs @@ -167,9 +167,12 @@ mergeDirect startbranch oldref branch resolvemerge = do createDirectoryIfMissing True d withIndexFile tmpi $ do - r <- inRepo (mergein d) <||> resolvemerge + merged <- inRepo (mergein d) + r <- if merged + then return True + else resolvemerge mergeDirectCleanup d (fromMaybe Git.Sha.emptyTree oldref) - mergeDirectCommit startbranch branch + mergeDirectCommit merged startbranch branch liftIO $ rename tmpi reali return r where @@ -179,14 +182,14 @@ mergeDirect startbranch oldref branch resolvemerge = do {- Commits after a direct mode merge is complete, and after the work - tree has been updated by mergeDirectCleanup. -} -mergeDirectCommit :: Maybe Git.Ref -> Git.Branch -> Annex () -mergeDirectCommit old branch = do +mergeDirectCommit :: Bool -> Maybe Git.Ref -> Git.Branch -> Annex () +mergeDirectCommit allowff old branch = do void preCommitDirect - gitdir <- fromRepo Git.localGitDir - let merge_head = gitdir </> "MERGE_HEAD" - let merge_msg = gitdir </> "MERGE_MSG" - let merge_mode = gitdir </> "MERGE_MODE" - ifM (maybe (return False) (\o -> inRepo $ Git.Branch.fastForwardable o branch) old) + d <- fromRepo Git.localGitDir + let merge_head = d </> "MERGE_HEAD" + let merge_msg = d </> "MERGE_MSG" + let merge_mode = d </> "MERGE_MODE" + ifM (pure allowff <&&> canff) ( inRepo $ Git.Branch.update Git.Ref.headRef branch -- fast forward , do msg <- liftIO $ @@ -196,6 +199,8 @@ mergeDirectCommit old branch = do Git.Ref.headRef [Git.Ref.headRef, branch] ) liftIO $ mapM_ nukeFile [merge_head, merge_msg, merge_mode] + where + canff = maybe (return False) (\o -> inRepo $ Git.Branch.fastForwardable o branch) old {- Cleans up after a direct mode merge. The merge must have been staged - in the index. Uses diff-index to compare the staged changes with |