summaryrefslogtreecommitdiff
path: root/Git/HashObject.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-02-20 15:20:36 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-02-20 15:22:21 -0400
commit6c0155efb7fd1ff7259095655093e0eab0e37e51 (patch)
treec3765e2dd4a7ba4b040468fc302a56279b7f886f /Git/HashObject.hs
parentac5cff3668ad1fc529d32058c31b30dd341c2547 (diff)
refactor
Diffstat (limited to 'Git/HashObject.hs')
-rw-r--r--Git/HashObject.hs23
1 files changed, 10 insertions, 13 deletions
diff --git a/Git/HashObject.hs b/Git/HashObject.hs
index 200fedbd2..5848d0144 100644
--- a/Git/HashObject.hs
+++ b/Git/HashObject.hs
@@ -10,16 +10,16 @@ module Git.HashObject where
import Common
import Git
import Git.Command
+import qualified Utility.CoProcess as CoProcess
-type HashObjectHandle = (PipeHandle, Handle, Handle)
+type HashObjectHandle = CoProcess.CoProcessHandle
{- Starts git hash-object and returns a handle. -}
hashObjectStart :: Repo -> IO HashObjectHandle
hashObjectStart repo = do
- r@(_, _, toh) <- hPipeBoth "git" $
- toCommand $ gitCommandLine params repo
- fileEncoding toh
- return r
+ h <- CoProcess.start "git" $ toCommand $ gitCommandLine params repo
+ CoProcess.query h fileEncoding (const $ return ())
+ return h
where
params =
[ Param "hash-object"
@@ -29,14 +29,11 @@ hashObjectStart repo = do
{- Stops git hash-object. -}
hashObjectStop :: HashObjectHandle -> IO ()
-hashObjectStop (pid, from, to) = do
- hClose to
- hClose from
- forceSuccess pid
+hashObjectStop = CoProcess.stop
{- Injects a file into git, returning the shas of the objects. -}
hashFile :: HashObjectHandle -> FilePath -> IO Sha
-hashFile (_, from, to) file = do
- hPutStrLn to file
- hFlush to
- Ref <$> hGetLine from
+hashFile h file = CoProcess.query h send receive
+ where
+ send to = hPutStrLn to file
+ receive from = Ref <$> hGetLine from