From d1ce927d95fe7c331cbff3317797a60aa288738b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 6 Jan 2016 16:30:49 -0400 Subject: unused: Bug fix when a new file was added to the annex, and then removed (but not git rmed). git still has the add staged in this case, so the content should not be unused and was wrongly treated as such. So, we need to look at both the file on disk to see if it's a annex link, and the file in the index too. lookupFile doesn't look in the index if the file is not present on disk. --- Command/Unused.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Command/Unused.hs') diff --git a/Command/Unused.hs b/Command/Unused.hs index 4353bd075..a643cf8e0 100644 --- a/Command/Unused.hs +++ b/Command/Unused.hs @@ -26,6 +26,7 @@ import qualified Git.LsFiles as LsFiles import qualified Git.DiffTree as DiffTree import qualified Remote import qualified Annex.Branch +import Annex.Link import Annex.CatFile import Types.Key import Types.RefSpec @@ -214,8 +215,12 @@ withKeysReferenced' mdir initial a = do Just dir -> inRepo $ LsFiles.inRepo [dir] go v [] = return v go v (f:fs) = do - x <- lookupFile f - case x of + mk <- getM id + [ isAnnexLink f + , liftIO (isPointerFile f) + , catKeyFile f + ] + case mk of Nothing -> go v fs Just k -> do !v' <- a k f v -- cgit v1.2.3