summaryrefslogtreecommitdiff
path: root/Git/Merge.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-06-09 18:01:30 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-06-09 19:40:28 -0400
commit7ce9a3793d91c210343a1e5ea60053dccab5a12c (patch)
tree5a5c262770118d790b0851e4ff6f1df4fddfaa39 /Git/Merge.hs
parent3eeba159f25cd53773c48d131cae796b366a43a4 (diff)
avoid bad commits after interrupted direct mode sync (or merge)
It was possible for a interrupted sync or merge in direct mode to leave the work tree out of sync with the last recorded commit. This would result in the next commit seeing files missing from the work tree, and committing their removal. Now, a direct mode merge happens not only in a throwaway work tree, but using a temporary index file, and without any commits or index changes being made until the real work tree has been updated. If the merge is interrupted, the work tree may have some updated files, but worst case a commit will redundantly commit changes that come from the merge. This commit was sponsored by Tony Cantor.
Diffstat (limited to 'Git/Merge.hs')
-rw-r--r--Git/Merge.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/Git/Merge.hs b/Git/Merge.hs
index 948e09e01..d661db978 100644
--- a/Git/Merge.hs
+++ b/Git/Merge.hs
@@ -1,6 +1,6 @@
{- git merging
-
- - Copyright 2012 Joey Hess <joey@kitenet.net>
+ - Copyright 2012, 2014 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -19,3 +19,15 @@ mergeNonInteractive branch
| otherwise = merge [Param "--no-edit", Param $ fromRef branch]
where
merge ps = runBool $ Param "merge" : ps
+
+{- Stage the merge into the index, but do not commit it.-}
+stageMerge :: Ref -> Repo -> IO Bool
+stageMerge branch = runBool
+ [ Param "merge"
+ , Param "--quiet"
+ , Param "--no-commit"
+ -- Without this, a fast-forward merge is done, since it involves no
+ -- commit.
+ , Param "--no-ff"
+ , Param $ fromRef branch
+ ]