summaryrefslogtreecommitdiff
path: root/Annex/AdjustedBranch.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-04-06 18:40:28 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-04-06 18:40:28 -0400
commit9de9f5aad4ec0275e3c544fcb26588ea0e755760 (patch)
tree492124ae7448a3e287b0c1f4af855aec727c736b /Annex/AdjustedBranch.hs
parent070b1a03392ab3962eb43f60f32fde5c1b9b70d2 (diff)
run out of tree merge with --no-ff
This is how direct mode does it too, and somehow, for reasons that currently escape me, this makes git merge not care if it's run with an empty work tree.
Diffstat (limited to 'Annex/AdjustedBranch.hs')
-rw-r--r--Annex/AdjustedBranch.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/Annex/AdjustedBranch.hs b/Annex/AdjustedBranch.hs
index a30dda809..994444626 100644
--- a/Annex/AdjustedBranch.hs
+++ b/Annex/AdjustedBranch.hs
@@ -32,6 +32,7 @@ import qualified Git.Ref
import qualified Git.Command
import qualified Git.Tree
import qualified Git.DiffTree
+import qualified Git.Merge
import Git.Tree (TreeItem(..))
import Git.Sha
import Git.Env
@@ -272,13 +273,16 @@ updateAdjustedBranch tomerge (origbranch, adj) commitmode = catchBoolIO $
withemptydir tmpwt $ withWorkTree tmpwt $ do
liftIO $ writeFile (tmpgit </> "HEAD") (fromRef updatedorig)
showAction $ "Merging into " ++ fromRef (Git.Ref.base origbranch)
- ifM (autoMergeFrom tomerge (Just origbranch) True commitmode)
- ( do
+ -- The --no-ff is important; it makes git
+ -- merge not care that the work tree is empty.
+ merged <- inRepo (Git.Merge.mergeNonInteractive' [Param "--no-ff"] tomerge commitmode)
+ <||> (resolveMerge (Just updatedorig) tomerge True <&&> commitResolvedMerge commitmode)
+ if merged
+ then do
!mergecommit <- liftIO $ extractSha <$> readFile (tmpgit </> "HEAD")
-- This is run after the commit lock is dropped.
return $ postmerge currbranch mergecommit
- , return $ return False
- )
+ else return $ return False
changestomerge Nothing _ = return $ return False
withemptydir d a = bracketIO setup cleanup (const a)
@@ -305,7 +309,7 @@ updateAdjustedBranch tomerge (origbranch, adj) commitmode = catchBoolIO $
adjmergecommit <- commitAdjustedTree' adjtree mergecommit
[mergecommit, currbranch]
showAction "Merging into adjusted branch"
- ifM (autoMergeFrom adjmergecommit (Just currbranch) False commitmode)
+ ifM (autoMergeFrom adjmergecommit (Just currbranch) commitmode)
-- The adjusted branch has a merge commit on top;
-- clean that up and propigate any changes made
-- in that merge to the origbranch.