From 84ffc8f7d265c8a685c1ea081c8a8871c7ee1b44 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 8 Jul 2014 13:54:42 -0400 Subject: 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. --- Annex/CatFile.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'Annex/CatFile.hs') diff --git a/Annex/CatFile.hs b/Annex/CatFile.hs index 6a778db03..2f8c43079 100644 --- a/Annex/CatFile.hs +++ b/Annex/CatFile.hs @@ -15,6 +15,7 @@ module Annex.CatFile ( catKey, catKeyFile, catKeyFileHEAD, + catLink, ) where import qualified Data.ByteString.Lazy as L @@ -77,21 +78,25 @@ catFileHandle = do catKey :: Ref -> FileMode -> Annex (Maybe Key) catKey = catKey' True -catKey' :: Bool -> Ref -> FileMode -> Annex (Maybe Key) -catKey' modeguaranteed ref mode +catKey' :: Bool -> Sha -> FileMode -> Annex (Maybe Key) +catKey' modeguaranteed sha mode | isSymLink mode = do - l <- fromInternalGitPath . decodeBS <$> get + l <- catLink modeguaranteed sha return $ if isLinkToAnnex l then fileKey $ takeFileName l else Nothing | otherwise = return Nothing + +{- Gets a symlink target. -} +catLink :: Bool -> Sha -> Annex String +catLink modeguaranteed sha = fromInternalGitPath . decodeBS <$> get where -- If the mode is not guaranteed to be correct, avoid -- buffering the whole file content, which might be large. -- 8192 is enough if it really is a symlink. get - | modeguaranteed = catObject ref - | otherwise = L.take 8192 <$> catObject ref + | modeguaranteed = catObject sha + | otherwise = L.take 8192 <$> catObject sha {- Looks up the key corresponding to the Ref using the running cat-file. - -- cgit v1.2.3