gitlib-libgit2 1.2.0 → 1.2.1
raw patch · 2 files changed
+24/−7 lines, 2 filesdep +base16-bytestringPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: base16-bytestring
API changes (from Hackage documentation)
+ Git.Libgit2: shaToOid :: ByteString -> IO (ForeignPtr C'git_oid)
+ Git.Libgit2: shaToText :: ByteString -> Text
+ Git.Libgit2: type SHA = ByteString
- Git.Libgit2: lgReadFromPack :: FilePath -> Text -> Bool -> IO (Maybe (C'git_otype, CSize, ByteString))
+ Git.Libgit2: lgReadFromPack :: FilePath -> ByteString -> Bool -> IO (Maybe (C'git_otype, CSize, ByteString))
- Git.Libgit2: oidToSha :: Ptr C'git_oid -> IO Text
+ Git.Libgit2: oidToSha :: Ptr C'git_oid -> IO ByteString
Files
- Git/Libgit2.hs +22/−6
- gitlib-libgit2.cabal +2/−1
Git/Libgit2.hs view
@@ -41,7 +41,10 @@ , lgLoadPackFileInMemory , lgReadFromPack , lgWithPackFile+ , SHA , oidToSha+ , shaToOid+ , shaToText , openLgRepository , runLgRepository , strToOid@@ -60,6 +63,7 @@ import Control.Monad.Trans.Resource import Data.Bits ((.|.)) import qualified Data.ByteString as B+import qualified Data.ByteString.Base16 as B16 import qualified Data.ByteString.Unsafe as BU import Data.HashMap.Strict (HashMap) import qualified Data.HashMap.Strict as HashMap@@ -1114,7 +1118,7 @@ debug "Discovering the hash used to identify the pack file" sha <- liftIO $ oidToSha =<< c'git_indexer_stream_hash idxPtr debug $ "The hash used is: " ++ show sha- return sha+ return (shaToText sha) strToOid :: String -> IO (ForeignPtr C'git_oid) strToOid oidStr = do@@ -1125,10 +1129,22 @@ when (r < 0) $ throwIO Git.OidCopyFailed return ptr -oidToSha :: Ptr C'git_oid -> IO Text-oidToSha oidPtr = allocaBytes 42 $ \oidStr ->- T.decodeUtf8 <$> (B.packCString =<< c'git_oid_tostr oidStr 41 oidPtr)+type SHA = B.ByteString +oidToSha :: Ptr C'git_oid -> IO B.ByteString+oidToSha oidPtr =+ B.packCStringLen (castPtr oidPtr, sizeOf (undefined :: C'git_oid))++shaToOid :: B.ByteString -> IO (ForeignPtr C'git_oid)+shaToOid bs = BU.unsafeUseAsCString bs $ \bytes -> do+ ptr <- mallocForeignPtr+ withForeignPtr ptr $ \ptr' -> do+ c'git_oid_fromraw ptr' (castPtr bytes)+ return ptr++shaToText :: B.ByteString -> Text+shaToText = T.decodeUtf8 . B16.encode+ lgWritePackFile :: Git.MonadGit m => FilePath -> LgRepository m () lgWritePackFile packFile = do -- jww (2013-04-23): This would be much more efficient (we already have@@ -1231,12 +1247,12 @@ debug "Calling function using in-memory odb" f odbPtr -lgReadFromPack :: FilePath -> Text -> Bool+lgReadFromPack :: FilePath -> B.ByteString -> Bool -> IO (Maybe (C'git_otype, CSize, B.ByteString)) lgReadFromPack idxPath sha metadataOnly = alloca $ \objectPtrPtr -> lgWithPackFile idxPath $ \odbPtr -> do- foid <- liftIO $ strToOid (T.unpack sha)+ foid <- liftIO $ shaToOid sha if metadataOnly then liftIO $ alloca $ \sizePtr -> alloca $ \typPtr -> do r <- withForeignPtr foid $
gitlib-libgit2.cabal view
@@ -1,5 +1,5 @@ Name: gitlib-libgit2-Version: 1.2.0+Version: 1.2.1 Synopsis: Libgit2 backend for gitlib License-file: LICENSE License: MIT@@ -41,6 +41,7 @@ , hlibgit2 >= 0.18.0.7 , attempt >= 0.4.0 , bytestring >= 0.9.2.1+ , base16-bytestring >= 0.1.1.5 , conduit >= 0.5.5 , containers >= 0.4.2 , data-default >= 0.5.0