aboutsummaryrefslogtreecommitdiff
path: root/Annex/AutoMerge.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-07-08 13:54:42 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-07-08 13:55:11 -0400
commit84ffc8f7d265c8a685c1ea081c8a8871c7ee1b44 (patch)
tree10c36135ebc8b298d18ee7f633fed61a5d31a2e4 /Annex/AutoMerge.hs
parent069e875da6d98f0d10c390541ccac733bea41e2b (diff)
Fix bug in automatic merge conflict resolution
When one side is an annexed symlink, and the other side is a non-annexed symlink. In this case, git-merge does not replace the annexed symlink in the work tree with the non-annexed symlink, which is different from it's handling of conflicts between annexed symlinks and regular files or directories. So, while git-annex generated the correct merge commit, the work tree didn't get updated to reflect it. See comments on bug for additional analysis. Did not add this to the test suite yet; just unloaded a truckload of firewood and am feeling lazy. This commit was sponsored by Adam Spiers.
Diffstat (limited to 'Annex/AutoMerge.hs')
-rw-r--r--Annex/AutoMerge.hs46
1 files changed, 35 insertions, 11 deletions
diff --git a/Annex/AutoMerge.hs b/Annex/AutoMerge.hs
index b5c4b911d..1c463003e 100644
--- a/Annex/AutoMerge.hs
+++ b/Annex/AutoMerge.hs
@@ -110,11 +110,11 @@ resolveMerge' (Just us) them u = do
makelink keyUs
-- Our side is annexed file, other side is not.
(Just keyUs, Nothing) -> resolveby $ do
- graftin them file
+ graftin them file LsFiles.valThem LsFiles.valThem
makelink keyUs
-- Our side is not annexed file, other side is.
(Nothing, Just keyThem) -> resolveby $ do
- graftin us file
+ graftin us file LsFiles.valUs LsFiles.valUs
makelink keyThem
-- Neither side is annexed file; cannot resolve.
(Nothing, Nothing) -> return Nothing
@@ -131,17 +131,41 @@ resolveMerge' (Just us) them u = do
makelink key = do
let dest = variantFile file key
l <- inRepo $ gitAnnexLink dest key
- ifM isDirect
- ( do
- d <- fromRepo gitAnnexMergeDir
- replaceFile (d </> dest) $ makeAnnexLink l
- , replaceFile dest $ makeAnnexLink l
- )
+ replacewithlink dest l
stageSymlink dest =<< hashSymlink l
- {- stage a graft of a directory or file from a branch -}
- graftin b item = Annex.Queue.addUpdateIndex
- =<< fromRepo (UpdateIndex.lsSubTree b item)
+ replacewithlink file link = ifM isDirect
+ ( do
+ d <- fromRepo gitAnnexMergeDir
+ replaceFile (d </> file) $ makeGitLink link
+ , replaceFile file $ makeGitLink link
+ )
+
+ {- Stage a graft of a directory or file from a branch.
+ -
+ - When there is a conflicted merge where one side is a directory
+ - or file, and the other side is a symlink, git merge always
+ - updates the work tree to contain the non-symlink. So, the
+ - directory or file will already be in the work tree correctly,
+ - and they just need to be staged into place. Do so by copying the
+ - index. (Note that this is also better than calling git-add
+ - because on a crippled filesystem, it preserves any symlink
+ - bits.)
+ -
+ - It's also possible for the branch to have a symlink in it,
+ - which is not a git-annex symlink. In this special case,
+ - git merge does not update the work tree to contain the symlink
+ - from the branch, so we have to do so manually.
+ -}
+ graftin b item select select' = do
+ Annex.Queue.addUpdateIndex
+ =<< fromRepo (UpdateIndex.lsSubTree b item)
+ when (select (LsFiles.unmergedBlobType u) == Just SymlinkBlob) $
+ case select' (LsFiles.unmergedSha u) of
+ Nothing -> noop
+ Just sha -> do
+ link <- catLink True sha
+ replacewithlink item link
resolveby a = do
{- Remove conflicted file from index so merge can be resolved. -}