summaryrefslogtreecommitdiff
path: root/Annex/HashObject.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-03-14 15:58:46 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-03-14 15:58:46 -0400
commit90db9740d0d64b34f2e46f57f8aaca235088734c (patch)
treeac4d7e1b03bfcc337d02569acb87a1481f610746 /Annex/HashObject.hs
parent9b29bd39c8dbf23bdf6930b51aba13992ccc49de (diff)
Sped up git-annex add in direct mode and v6 by using git hash-object --batch.
Speeds up hashSymlink and hashPointerFile.
Diffstat (limited to 'Annex/HashObject.hs')
-rw-r--r--Annex/HashObject.hs19
1 files changed, 6 insertions, 13 deletions
diff --git a/Annex/HashObject.hs b/Annex/HashObject.hs
index aa8c2a174..16f741407 100644
--- a/Annex/HashObject.hs
+++ b/Annex/HashObject.hs
@@ -12,38 +12,31 @@ module Annex.HashObject (
hashObjectStop,
) where
-import qualified Data.ByteString.Lazy as L
-import qualified Data.Map as M
-import System.PosixCompat.Types
-
import Annex.Common
-import qualified Git
import qualified Git.HashObject
import qualified Annex
import Git.Types
-import Git.FilePath
-import qualified Git.Ref
-import Annex.Link
hashObjectHandle :: Annex Git.HashObject.HashObjectHandle
hashObjectHandle = maybe startup return =<< Annex.getState Annex.hashobjecthandle
where
startup = do
- inRepo $ Git.hashObjectStart
+ h <- inRepo $ Git.HashObject.hashObjectStart
Annex.changeState $ \s -> s { Annex.hashobjecthandle = Just h }
return h
hashObjectStop :: Annex ()
-hashObjectStop = maybe noop stop =<< Annex.hashobjecthandle
+hashObjectStop = maybe noop stop =<< Annex.getState Annex.hashobjecthandle
where
stop h = do
- liftIO $ Git.hashObjectStop h
+ liftIO $ Git.HashObject.hashObjectStop h
Annex.changeState $ \s -> s { Annex.hashobjecthandle = Nothing }
+ return ()
hashFile :: FilePath -> Annex Sha
hashFile f = do
h <- hashObjectHandle
- Git.HashObject.hashFile h f
+ liftIO $ Git.HashObject.hashFile h f
{- Note that the content will be written to a temp file.
- So it may be faster to use Git.HashObject.hashObject for large
@@ -51,4 +44,4 @@ hashFile f = do
hashBlob :: String -> Annex Sha
hashBlob content = do
h <- hashObjectHandle
- Git.HashObject.hashFile h content
+ liftIO $ Git.HashObject.hashBlob h content