diff options
author | Joey Hess <joey@kitenet.net> | 2014-06-09 18:01:30 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-06-09 19:40:28 -0400 |
commit | 7ce9a3793d91c210343a1e5ea60053dccab5a12c (patch) | |
tree | 5a5c262770118d790b0851e4ff6f1df4fddfaa39 /Annex/AutoMerge.hs | |
parent | 3eeba159f25cd53773c48d131cae796b366a43a4 (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 'Annex/AutoMerge.hs')
-rw-r--r-- | Annex/AutoMerge.hs | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/Annex/AutoMerge.hs b/Annex/AutoMerge.hs index 2ed26b78f..e6f7e0497 100644 --- a/Annex/AutoMerge.hs +++ b/Annex/AutoMerge.hs @@ -17,7 +17,6 @@ import qualified Git.LsFiles as LsFiles import qualified Git.UpdateIndex as UpdateIndex import qualified Git.Merge import qualified Git.Ref -import qualified Git.Sha import qualified Git import Git.Types (BlobType(..)) import Config @@ -38,12 +37,7 @@ autoMergeFrom branch currbranch = do Just b -> go =<< inRepo (Git.Ref.sha b) where go old = ifM isDirect - ( do - d <- fromRepo gitAnnexMergeDir - r <- inRepo (mergeDirect d branch) - <||> resolveMerge old branch - mergeDirectCleanup d (fromMaybe Git.Sha.emptyTree old) Git.Ref.headRef - return r + ( mergeDirect currbranch old branch (resolveMerge old branch) , inRepo (Git.Merge.mergeNonInteractive branch) <||> resolveMerge old branch ) @@ -70,9 +64,11 @@ autoMergeFrom branch currbranch = do - - In indirect mode, the merge is resolved in the work tree and files - staged, to clean up from a conflicted merge that was run in the work - - tree. In direct mode, the work tree is not touched here; files are - - staged to the index, and written to the gitAnnexMergeDir, and later - - mergeDirectCleanup handles updating the work tree. + - 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 + - later mergeDirectCleanup handles updating the work tree. -} resolveMerge :: Maybe Git.Ref -> Git.Ref -> Annex Bool resolveMerge us them = do @@ -92,14 +88,13 @@ resolveMerge us them = do unlessM isDirect $ cleanConflictCruft mergedfs top Annex.Queue.flush - whenM isDirect $ - void preCommitDirect - void $ inRepo $ Git.Command.runBool - [ Param "commit" - , Param "--no-verify" - , Param "-m" - , Param "git-annex automatic merge conflict fix" - ] + unlessM isDirect $ do + void $ inRepo $ Git.Command.runBool + [ Param "commit" + , Param "--no-verify" + , Param "-m" + , Param "git-annex automatic merge conflict fix" + ] showLongNote "Merge conflict was automatically resolved; you may want to examine the result." return merged |