cleanup
This commit is contained in:
parent
7e17151e69
commit
cac130b205
3 changed files with 18 additions and 23 deletions
|
@ -25,12 +25,12 @@ import qualified Utility.CoProcess as CoProcess
|
||||||
|
|
||||||
type CatFileHandle = CoProcess.CoProcessHandle
|
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 -> IO CatFileHandle
|
||||||
catFileStart repo = CoProcess.start "git" $ toCommand $
|
catFileStart = CoProcess.start "git" . toCommand . gitCommandLine
|
||||||
gitCommandLine [Param "cat-file", Param "--batch"] repo
|
[ Param "cat-file"
|
||||||
|
, Param "--batch"
|
||||||
|
]
|
||||||
|
|
||||||
{- Stops git cat-file. -}
|
|
||||||
catFileStop :: CatFileHandle -> IO ()
|
catFileStop :: CatFileHandle -> IO ()
|
||||||
catFileStop = CoProcess.stop
|
catFileStop = CoProcess.stop
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,11 @@ type CheckAttrHandle = (CoProcess.CoProcessHandle, [Attr], String)
|
||||||
type Attr = String
|
type Attr = String
|
||||||
|
|
||||||
{- Starts git check-attr running to look up the specified gitattributes
|
{- 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 :: [Attr] -> Repo -> IO CheckAttrHandle
|
||||||
checkAttrStart attrs repo = do
|
checkAttrStart attrs repo = do
|
||||||
cwd <- getCurrentDirectory
|
cwd <- getCurrentDirectory
|
||||||
h <- CoProcess.start "git" $ toCommand $
|
h <- CoProcess.start "git" $ toCommand $ gitCommandLine params repo
|
||||||
gitCommandLine params repo
|
|
||||||
CoProcess.query h fileEncoding fileEncoding
|
|
||||||
return (h, attrs, cwd)
|
return (h, attrs, cwd)
|
||||||
where
|
where
|
||||||
params =
|
params =
|
||||||
|
@ -33,7 +31,6 @@ checkAttrStart attrs repo = do
|
||||||
] ++ map Param attrs ++
|
] ++ map Param attrs ++
|
||||||
[ Param "--" ]
|
[ Param "--" ]
|
||||||
|
|
||||||
{- Stops git check-attr. -}
|
|
||||||
checkAttrStop :: CheckAttrHandle -> IO ()
|
checkAttrStop :: CheckAttrHandle -> IO ()
|
||||||
checkAttrStop (h, _, _) = CoProcess.stop h
|
checkAttrStop (h, _, _) = CoProcess.stop h
|
||||||
|
|
||||||
|
@ -46,8 +43,11 @@ checkAttr (h, attrs, cwd) want file = do
|
||||||
[v] -> return v
|
[v] -> return v
|
||||||
_ -> error $ "unable to determine " ++ want ++ " attribute of " ++ file
|
_ -> error $ "unable to determine " ++ want ++ " attribute of " ++ file
|
||||||
where
|
where
|
||||||
send to = hPutStr to $ file' ++ "\0"
|
send to = do
|
||||||
|
fileEncoding to
|
||||||
|
hPutStr to $ file' ++ "\0"
|
||||||
receive from = forM attrs $ \attr -> do
|
receive from = forM attrs $ \attr -> do
|
||||||
|
fileEncoding from
|
||||||
l <- hGetLine from
|
l <- hGetLine from
|
||||||
return (attr, attrvalue attr l)
|
return (attr, attrvalue attr l)
|
||||||
{- Before git 1.7.7, git check-attr worked best with
|
{- Before git 1.7.7, git check-attr worked best with
|
||||||
|
|
|
@ -14,20 +14,13 @@ import qualified Utility.CoProcess as CoProcess
|
||||||
|
|
||||||
type HashObjectHandle = CoProcess.CoProcessHandle
|
type HashObjectHandle = CoProcess.CoProcessHandle
|
||||||
|
|
||||||
{- Starts git hash-object and returns a handle. -}
|
|
||||||
hashObjectStart :: Repo -> IO HashObjectHandle
|
hashObjectStart :: Repo -> IO HashObjectHandle
|
||||||
hashObjectStart repo = do
|
hashObjectStart = CoProcess.start "git" . toCommand . gitCommandLine
|
||||||
h <- CoProcess.start "git" $ toCommand $ gitCommandLine params repo
|
|
||||||
CoProcess.query h fileEncoding (const $ return ())
|
|
||||||
return h
|
|
||||||
where
|
|
||||||
params =
|
|
||||||
[ Param "hash-object"
|
[ Param "hash-object"
|
||||||
, Param "-w"
|
, Param "-w"
|
||||||
, Param "--stdin-paths"
|
, Param "--stdin-paths"
|
||||||
]
|
]
|
||||||
|
|
||||||
{- Stops git hash-object. -}
|
|
||||||
hashObjectStop :: HashObjectHandle -> IO ()
|
hashObjectStop :: HashObjectHandle -> IO ()
|
||||||
hashObjectStop = CoProcess.stop
|
hashObjectStop = CoProcess.stop
|
||||||
|
|
||||||
|
@ -35,5 +28,7 @@ hashObjectStop = CoProcess.stop
|
||||||
hashFile :: HashObjectHandle -> FilePath -> IO Sha
|
hashFile :: HashObjectHandle -> FilePath -> IO Sha
|
||||||
hashFile h file = CoProcess.query h send receive
|
hashFile h file = CoProcess.query h send receive
|
||||||
where
|
where
|
||||||
send to = hPutStrLn to file
|
send to = do
|
||||||
|
fileEncoding to
|
||||||
|
hPutStrLn to file
|
||||||
receive from = Ref <$> hGetLine from
|
receive from = Ref <$> hGetLine from
|
||||||
|
|
Loading…
Reference in a new issue