aboutsummaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-04 15:31:53 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-04 17:24:12 -0400
commitf5ce1a15d7a35b85ffa938ee950f4749bf445939 (patch)
tree5b0b192fc789fa4b6004a4e43144853af7dde812 /Command
parentc69cd93af187c55793052db169abe0d3fb33ef60 (diff)
add test case & fix conflict resolution bug on Windows & FAT
Fix bug in automatic merge conflict resolution code when used on a filesystem not supporting symlinks, which resulted in it losing track of the symlink bit of annexed files. This was the underlying bug that was causing another test to fail, which got worked around in f5d0c8f0bf7f018479eb4da7e8c41598b7aacb7d. I've chosen to keep 2 separate test cases since the old test case only detected the problem accidentially. Test suite passes on FAT & in windows, as well as on proper unix systems. This commit was sponsored by Ellis Whitehead.
Diffstat (limited to 'Command')
-rw-r--r--Command/Sync.hs31
1 files changed, 26 insertions, 5 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs
index c9493b2a4..331f5d03f 100644
--- a/Command/Sync.hs
+++ b/Command/Sync.hs
@@ -392,14 +392,10 @@ resolveMerge' u
-- Our side is annexed, other side is not.
(Just keyUs, Nothing) -> do
ifM isDirect
- -- Move newly added non-annexed object
- -- out of direct mode merge directory.
( do
removeoldfile keyUs
makelink keyUs
- d <- fromRepo gitAnnexMergeDir
- liftIO $ rename (d </> file) file
- -- cleaup tree after git merge
+ movefromdirectmerge file
, do
unstageoldfile
makelink keyUs
@@ -433,6 +429,31 @@ resolveMerge' u
getKey select = case select (LsFiles.unmergedSha u) of
Nothing -> return Nothing
Just sha -> catKey sha symLinkMode
+
+ {- Move something out of the direct mode merge directory and into
+ - the git work tree.
+ -
+ - On a filesystem not supporting symlinks, this is complicated
+ - because a directory may contain annex links, but just
+ - moving them into the work tree will not let git know they are
+ - symlinks.
+ -
+ - Also, if the content of the file is available, make it available
+ - in direct mode.
+ -}
+ movefromdirectmerge item = do
+ d <- fromRepo gitAnnexMergeDir
+ liftIO $ rename (d </> item) item
+ mapM_ setuplink =<< liftIO (dirContentsRecursive item)
+ setuplink f = do
+ v <- getAnnexLinkTarget f
+ case v of
+ Nothing -> noop
+ Just target -> do
+ unlessM (coreSymlinks <$> Annex.getGitConfig) $
+ addAnnexLink target f
+ maybe noop (flip toDirect f)
+ (fileKey (takeFileName target))
{- git-merge moves conflicting files away to files
- named something like f~HEAD or f~branch, but the