summaryrefslogtreecommitdiff
path: root/Annex/AutoMerge.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-29 16:33:06 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-29 16:35:34 -0400
commit3c645368da1c9ee0e963fc60fe2ff9611bed92da (patch)
tree247a8c9d26ba294f6af5b067f1f1a834124537b9 /Annex/AutoMerge.hs
parentfecb9b63b21326836341bcf773d7c4c2d345c11e (diff)
avoid renaming file when auto-resolving conflict in annex pointer
This is a behavior change for merge conflicts between locked files that both pointed to the same key, in different ways. Before, the conflict was resolved, but the file was renamed to .variant. This was unnecessary, because there was only one variant. Of course, this also handles conflicts between unlocked and locked, or even two unlocked files with different pointer contents.
Diffstat (limited to 'Annex/AutoMerge.hs')
-rw-r--r--Annex/AutoMerge.hs24
1 files changed, 13 insertions, 11 deletions
diff --git a/Annex/AutoMerge.hs b/Annex/AutoMerge.hs
index 89bcff0d6..246a4858b 100644
--- a/Annex/AutoMerge.hs
+++ b/Annex/AutoMerge.hs
@@ -132,13 +132,15 @@ resolveMerge' unstagedmap (Just us) them u = do
makeannexlink keyUs LsFiles.valUs
makeannexlink keyThem LsFiles.valThem
liftIO $ nukeFile file
- | otherwise -> resolveby [keyUs, keyThem] $ do
+ | otherwise -> do
-- Only resolve using symlink when both
- -- were locked, otherwise use unlocked pointer.
+ -- were locked, otherwise use unlocked
+ -- pointer.
+ -- In either case, keep original filename.
if islocked LsFiles.valUs && islocked LsFiles.valThem
- then makesymlink keyUs
- else makepointer keyUs
- liftIO $ nukeFile file
+ then makesymlink keyUs file
+ else makepointer keyUs file
+ return ([keyUs, keyThem], Just file)
-- Our side is annexed file, other side is not.
(Just keyUs, Nothing) -> resolveby [keyUs] $ do
graftin them file LsFiles.valThem LsFiles.valThem
@@ -160,11 +162,12 @@ resolveMerge' unstagedmap (Just us) them u = do
islocked select = select (LsFiles.unmergedBlobType u) == Just SymlinkBlob
makeannexlink key select
- | islocked select = makesymlink key
- | otherwise = makepointer key
+ | islocked select = makesymlink key dest
+ | otherwise = makepointer key dest
+ where
+ dest = variantFile file key
- makesymlink key = do
- let dest = variantFile file key
+ makesymlink key dest = do
l <- calcRepo $ gitAnnexLink dest key
replacewithlink dest l
stageSymlink dest =<< hashSymlink l
@@ -176,8 +179,7 @@ resolveMerge' unstagedmap (Just us) them u = do
, replaceFile dest $ makeGitLink link
)
- makepointer key = do
- let dest = variantFile file key
+ makepointer key dest = do
unlessM (reuseOldFile unstagedmap key file dest) $ do
r <- linkFromAnnex key dest
case r of