diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-10-15 14:22:46 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-10-15 14:22:46 -0400 |
commit | cb5ca6e981a9dedce90d9ac7e1785c5ae5841723 (patch) | |
tree | d0a926ff1776c7a242a111b72afe76455fc77bdb /Annex | |
parent | 4b6bff79f25d5567deb8b266cccb96744f75d057 (diff) |
avoid making post-merge-conflict-resolution commit when no conflicts were resolved
sync, merge, assistant: When git merge failed for a reason other than a
conflicted merge, such as a crippled filesystem not allowing particular
characters in filenames, git-annex would make a merge commit that could
omit such files or otherwise be bad. Fixed by aborting the whole merge
process when git merge fails for any reason other than a merge conflict.
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/AutoMerge.hs | 4 | ||||
-rw-r--r-- | Annex/Direct.hs | 16 |
2 files changed, 13 insertions, 7 deletions
diff --git a/Annex/AutoMerge.hs b/Annex/AutoMerge.hs index 825dde443..bfbe71dc2 100644 --- a/Annex/AutoMerge.hs +++ b/Annex/AutoMerge.hs @@ -77,6 +77,10 @@ autoMergeFrom branch currbranch commitmode = do - In direct mode, the work tree is not touched here; files are staged to - the index, and written to the gitAnnexMergeDir, for later handling by - the direct mode merge code. + - + - Returns false when there are no merge conflicts to resolve. + - A git merge can fail for other reasons, and this allows detecting + - such failures. -} resolveMerge :: Maybe Git.Ref -> Git.Ref -> Annex Bool resolveMerge us them = do diff --git a/Annex/Direct.hs b/Annex/Direct.hs index 35a5b5013..eb8d4842d 100644 --- a/Annex/Direct.hs +++ b/Annex/Direct.hs @@ -173,16 +173,18 @@ mergeDirect startbranch oldref branch resolvemerge commitmode = exclusively $ do withIndexFile tmpi $ do merged <- stageMerge d branch commitmode - r <- if merged + ok <- if merged then return True else resolvemerge - mergeDirectCleanup d (fromMaybe Git.Sha.emptyTree oldref) - mergeDirectCommit merged startbranch branch commitmode + if ok + then do + mergeDirectCleanup d (fromMaybe Git.Sha.emptyTree oldref) + mergeDirectCommit merged startbranch branch commitmode + liftIO $ whenM (doesFileExist tmpi) $ + rename tmpi reali + else liftIO $ nukeFile tmpi - liftIO $ whenM (doesFileExist tmpi) $ - rename tmpi reali - - return r + return ok where exclusively = withExclusiveLock gitAnnexMergeLock |