summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-07 15:45:08 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-07 15:45:08 -0400
commitad2339e17f69373e75aae5d1394de5d76d94c790 (patch)
treeffe51f9c236dadd340802c4604dcdd3fc190c9e9 /Annex
parentee0c34c8f2f94775b39ef10ed580cab47d2f929c (diff)
require "annex/objects/" before key in pointer files
This removes ambiguity, because while someone might have "WORM--foo" in a file that's not intended to be a git-annex pointer file, "annex/objects/WORM--foo" is less likely. Also, ee0c34c8f2f94775b39ef10ed580cab47d2f929c had a caveat about symlink targets being parsed as pointer files, and now the same parser is used for both. I did not include any hash directories before the key in the pointer file, as they're not needed. However, if they were included, the parser would still work ok.
Diffstat (limited to 'Annex')
-rw-r--r--Annex/CatFile.hs18
1 files changed, 7 insertions, 11 deletions
diff --git a/Annex/CatFile.hs b/Annex/CatFile.hs
index 47ea86a31..7c0022ca5 100644
--- a/Annex/CatFile.hs
+++ b/Annex/CatFile.hs
@@ -83,16 +83,8 @@ catFileStop = do
{- From ref to a symlink or a pointer file, get the key. -}
catKey :: Ref -> Annex (Maybe Key)
-catKey ref = do
- o <- catObject ref
- if L.length o > maxsz
- then return Nothing -- too big
- else do
- let l = decodeBS o
- let l' = fromInternalGitPath l
- return $ if isLinkToAnnex l'
- then fileKey $ takeFileName l'
- else parsePointer l
+catKey ref = parsePointer . fromInternalGitPath . decodeBS . L.take maxsz
+ <$> catObject ref
where
-- Want to avoid buffering really big files in git into memory.
-- 8192 bytes is plenty for a pointer to a key.
@@ -102,7 +94,11 @@ catKey ref = do
{- Only look at the first line of a pointer file. -}
parsePointer :: String -> Maybe Key
-parsePointer s = headMaybe (lines s) >>= file2key
+parsePointer s = headMaybe (lines s) >>= go
+ where
+ go l
+ | isLinkToAnnex l = file2key $ takeFileName l
+ | otherwise = Nothing
{- Gets a symlink target. -}
catSymLinkTarget :: Sha -> Annex String