aboutsummaryrefslogtreecommitdiff
path: root/Annex/CatFile.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-09 14:25:33 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-09 14:27:43 -0400
commit26a0189fcb54290b1bad3afadef93804bb818987 (patch)
tree5da0740317a36d0720bde8556133d171aef402ef /Annex/CatFile.hs
parent9687457dca30f531d19e023a32e00ffe6fd2d738 (diff)
refactor and improve pointer file handling code
Diffstat (limited to 'Annex/CatFile.hs')
-rw-r--r--Annex/CatFile.hs20
1 files changed, 2 insertions, 18 deletions
diff --git a/Annex/CatFile.hs b/Annex/CatFile.hs
index 7c0022ca5..aefccd424 100644
--- a/Annex/CatFile.hs
+++ b/Annex/CatFile.hs
@@ -14,7 +14,6 @@ module Annex.CatFile (
catFileHandle,
catFileStop,
catKey,
- parsePointer,
catKeyFile,
catKeyFileHEAD,
catSymLinkTarget,
@@ -31,7 +30,7 @@ import qualified Annex
import Git.Types
import Git.FilePath
import qualified Git.Ref
-import Types.Key
+import Annex.Link
catFile :: Git.Branch -> FilePath -> Annex L.ByteString
catFile branch file = do
@@ -83,22 +82,7 @@ catFileStop = do
{- From ref to a symlink or a pointer file, get the key. -}
catKey :: Ref -> Annex (Maybe Key)
-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.
- -- Pad some more to allow for any pointer files that might have
- -- lines after the key explaining what the file is used for.
- maxsz = 81920
-
-{- Only look at the first line of a pointer file. -}
-parsePointer :: String -> Maybe Key
-parsePointer s = headMaybe (lines s) >>= go
- where
- go l
- | isLinkToAnnex l = file2key $ takeFileName l
- | otherwise = Nothing
+catKey ref = parseLinkOrPointer <$> catObject ref
{- Gets a symlink target. -}
catSymLinkTarget :: Sha -> Annex String