aboutsummaryrefslogtreecommitdiff
path: root/Annex/WorkTree.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-30 14:23:31 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-30 14:23:31 -0400
commit97f6b63c1cc2c6e03849edde9995135270a520a8 (patch)
treef4bc77bd288b9b1cac586939c9720dc7bca72ede /Annex/WorkTree.hs
parent2b8e7b4041a4fa47caaf3507317c5b96f6f3e9e4 (diff)
fix failing git-annex unused test case in v6
WorkTree.lookupFile was finding a key for a file that's deleted from the work tree, which is different than the v5 behavior (though perhaps the same as the direct mode behavior). Fix by checking that the work tree file exists before catting its key. Hopefully this won't slow down much, probably the catKey is much more expensive. I can't see any way to optimise this, except perhaps to make Command.Unused check if work tree files exist before/after calling lookupFile. But, it seems better to make lookupFile really only find keys for worktree files; that's what it's intended to do.
Diffstat (limited to 'Annex/WorkTree.hs')
-rw-r--r--Annex/WorkTree.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/Annex/WorkTree.hs b/Annex/WorkTree.hs
index c824e7fc5..85ea9a62e 100644
--- a/Annex/WorkTree.hs
+++ b/Annex/WorkTree.hs
@@ -13,7 +13,7 @@ import Annex.CatFile
import Annex.Version
import Config
-{- Looks up the key corresponding to an annexed file,
+{- Looks up the key corresponding to an annexed file in the work tree,
- by examining what the file links to.
-
- An unlocked file will not have a link on disk, so fall back to
@@ -25,7 +25,10 @@ lookupFile file = do
case mkey of
Just key -> makeret key
Nothing -> ifM (versionSupportsUnlockedPointers <||> isDirect)
- ( maybe (return Nothing) makeret =<< catKeyFile file
+ ( ifM (liftIO $ doesFileExist file)
+ ( maybe (return Nothing) makeret =<< catKeyFile file
+ , return Nothing
+ )
, return Nothing
)
where