diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-12-09 14:25:33 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-12-09 14:27:43 -0400 |
commit | 26a0189fcb54290b1bad3afadef93804bb818987 (patch) | |
tree | 5da0740317a36d0720bde8556133d171aef402ef /Command | |
parent | 9687457dca30f531d19e023a32e00ffe6fd2d738 (diff) |
refactor and improve pointer file handling code
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Smudge.hs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/Command/Smudge.hs b/Command/Smudge.hs index e08afed6b..f9f819bec 100644 --- a/Command/Smudge.hs +++ b/Command/Smudge.hs @@ -9,16 +9,14 @@ module Command.Smudge where import Common.Annex import Command -import Types.Key import Annex.Content -import Annex.CatFile +import Annex.Link import Annex.MetaData import Annex.FileMatcher import Types.KeySource import Backend import Logs.Location import qualified Database.AssociatedFiles as AssociatedFiles -import Git.FilePath import qualified Data.ByteString.Lazy as B @@ -46,16 +44,13 @@ seek o = commandAction $ -- available annex object, should output its content. smudge :: FilePath -> CommandStart smudge file = do - liftIO $ fileEncoding stdin - s <- liftIO $ hGetContents stdin - case parsePointer s of - Nothing -> liftIO $ putStr s + b <- liftIO $ B.hGetContents stdin + case parseLinkOrPointer b of + Nothing -> liftIO $ B.putStr b Just k -> do updateAssociatedFiles k file content <- calcRepo (gitAnnexLocation k) - liftIO $ maybe - (putStr s) - (B.hPut stdout) + liftIO $ B.hPut stdout . fromMaybe b =<< catchMaybeIO (B.readFile content) stop @@ -102,11 +97,8 @@ ingest file = do =<< liftIO (getFileStatus file) return k --- Could add a newline and some text explaining this file is a pointer. --- parsePointer only looks at the first line. emitPointer :: Key -> IO () -emitPointer k = putStrLn $ toInternalGitPath $ - pathSeparator:objectDir </> key2file k +emitPointer = putStrLn . formatPointer updateAssociatedFiles :: Key -> FilePath -> Annex () updateAssociatedFiles k f = do |