summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-02-21 00:16:24 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-02-21 00:16:24 -0400
commitcac130b205fca9fc45833296dc326b3fd6385163 (patch)
treebd27ca58e17fa0fd2daa79011257b2d5b22bf717
parent7e17151e69fcd86fd5cb90dd61ff55d2d017fee7 (diff)
cleanup
-rw-r--r--Git/CatFile.hs8
-rw-r--r--Git/CheckAttr.hs12
-rw-r--r--Git/HashObject.hs21
3 files changed, 18 insertions, 23 deletions
diff --git a/Git/CatFile.hs b/Git/CatFile.hs
index 2987a9d9d..41ecb362c 100644
--- a/Git/CatFile.hs
+++ b/Git/CatFile.hs
@@ -25,12 +25,12 @@ import qualified Utility.CoProcess as CoProcess
type CatFileHandle = CoProcess.CoProcessHandle
-{- Starts git cat-file running in batch mode in a repo and returns a handle. -}
catFileStart :: Repo -> IO CatFileHandle
-catFileStart repo = CoProcess.start "git" $ toCommand $
- gitCommandLine [Param "cat-file", Param "--batch"] repo
+catFileStart = CoProcess.start "git" . toCommand . gitCommandLine
+ [ Param "cat-file"
+ , Param "--batch"
+ ]
-{- Stops git cat-file. -}
catFileStop :: CatFileHandle -> IO ()
catFileStop = CoProcess.stop
diff --git a/Git/CheckAttr.hs b/Git/CheckAttr.hs
index 65e8e03d8..6b321f8b8 100644
--- a/Git/CheckAttr.hs
+++ b/Git/CheckAttr.hs
@@ -18,13 +18,11 @@ type CheckAttrHandle = (CoProcess.CoProcessHandle, [Attr], String)
type Attr = String
{- Starts git check-attr running to look up the specified gitattributes
- - values and return a handle. -}
+ - values and returns a handle. -}
checkAttrStart :: [Attr] -> Repo -> IO CheckAttrHandle
checkAttrStart attrs repo = do
cwd <- getCurrentDirectory
- h <- CoProcess.start "git" $ toCommand $
- gitCommandLine params repo
- CoProcess.query h fileEncoding fileEncoding
+ h <- CoProcess.start "git" $ toCommand $ gitCommandLine params repo
return (h, attrs, cwd)
where
params =
@@ -33,7 +31,6 @@ checkAttrStart attrs repo = do
] ++ map Param attrs ++
[ Param "--" ]
-{- Stops git check-attr. -}
checkAttrStop :: CheckAttrHandle -> IO ()
checkAttrStop (h, _, _) = CoProcess.stop h
@@ -46,8 +43,11 @@ checkAttr (h, attrs, cwd) want file = do
[v] -> return v
_ -> error $ "unable to determine " ++ want ++ " attribute of " ++ file
where
- send to = hPutStr to $ file' ++ "\0"
+ send to = do
+ fileEncoding to
+ hPutStr to $ file' ++ "\0"
receive from = forM attrs $ \attr -> do
+ fileEncoding from
l <- hGetLine from
return (attr, attrvalue attr l)
{- Before git 1.7.7, git check-attr worked best with
diff --git a/Git/HashObject.hs b/Git/HashObject.hs
index 5848d0144..617e5ac28 100644
--- a/Git/HashObject.hs
+++ b/Git/HashObject.hs
@@ -14,20 +14,13 @@ import qualified Utility.CoProcess as CoProcess
type HashObjectHandle = CoProcess.CoProcessHandle
-{- Starts git hash-object and returns a handle. -}
hashObjectStart :: Repo -> IO HashObjectHandle
-hashObjectStart repo = do
- h <- CoProcess.start "git" $ toCommand $ gitCommandLine params repo
- CoProcess.query h fileEncoding (const $ return ())
- return h
- where
- params =
- [ Param "hash-object"
- , Param "-w"
- , Param "--stdin-paths"
- ]
+hashObjectStart = CoProcess.start "git" . toCommand . gitCommandLine
+ [ Param "hash-object"
+ , Param "-w"
+ , Param "--stdin-paths"
+ ]
-{- Stops git hash-object. -}
hashObjectStop :: HashObjectHandle -> IO ()
hashObjectStop = CoProcess.stop
@@ -35,5 +28,7 @@ hashObjectStop = CoProcess.stop
hashFile :: HashObjectHandle -> FilePath -> IO Sha
hashFile h file = CoProcess.query h send receive
where
- send to = hPutStrLn to file
+ send to = do
+ fileEncoding to
+ hPutStrLn to file
receive from = Ref <$> hGetLine from