finished where indentation changes
This commit is contained in:
parent
b77290cecc
commit
f87a781aa6
68 changed files with 1619 additions and 1628 deletions
|
@ -48,28 +48,28 @@ catObject h object = maybe L.empty fst <$> catObjectDetails h object
|
|||
{- Gets both the content of an object, and its Sha. -}
|
||||
catObjectDetails :: CatFileHandle -> Ref -> IO (Maybe (L.ByteString, Sha))
|
||||
catObjectDetails h object = CoProcess.query h send receive
|
||||
where
|
||||
send to = do
|
||||
fileEncoding to
|
||||
hPutStrLn to $ show object
|
||||
receive from = do
|
||||
fileEncoding from
|
||||
header <- hGetLine from
|
||||
case words header of
|
||||
[sha, objtype, size]
|
||||
| length sha == shaSize &&
|
||||
isJust (readObjectType objtype) ->
|
||||
case reads size of
|
||||
[(bytes, "")] -> readcontent bytes from sha
|
||||
_ -> dne
|
||||
| otherwise -> dne
|
||||
_
|
||||
| header == show object ++ " missing" -> dne
|
||||
| otherwise -> error $ "unknown response from git cat-file " ++ show (header, object)
|
||||
readcontent bytes from sha = do
|
||||
content <- S.hGet from bytes
|
||||
c <- hGetChar from
|
||||
when (c /= '\n') $
|
||||
error "missing newline from git cat-file"
|
||||
return $ Just (L.fromChunks [content], Ref sha)
|
||||
dne = return Nothing
|
||||
where
|
||||
send to = do
|
||||
fileEncoding to
|
||||
hPutStrLn to $ show object
|
||||
receive from = do
|
||||
fileEncoding from
|
||||
header <- hGetLine from
|
||||
case words header of
|
||||
[sha, objtype, size]
|
||||
| length sha == shaSize &&
|
||||
isJust (readObjectType objtype) ->
|
||||
case reads size of
|
||||
[(bytes, "")] -> readcontent bytes from sha
|
||||
_ -> dne
|
||||
| otherwise -> dne
|
||||
_
|
||||
| header == show object ++ " missing" -> dne
|
||||
| otherwise -> error $ "unknown response from git cat-file " ++ show (header, object)
|
||||
readcontent bytes from sha = do
|
||||
content <- S.hGet from bytes
|
||||
c <- hGetChar from
|
||||
when (c /= '\n') $
|
||||
error "missing newline from git cat-file"
|
||||
return $ Just (L.fromChunks [content], Ref sha)
|
||||
dne = return Nothing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue