fix filename encoding for git cat-file

The filename sent to git cat-file needs to be sent on a File encoded handle.

Also set the read handle to use the File encoding, so that any error
message mentioning the filename is received properly.

The actual file content is read using Data.ByteString.Char8, which
will ignore the read handle's encoding, so this won't change that.
(Whether that is entirely correct remains to be seen.)
This commit is contained in:
Joey Hess 2012-02-26 14:11:50 -04:00
parent b889581945
commit 00d814aecc

View file

@ -43,8 +43,11 @@ catFile h branch file = catObject h $ Ref $ show branch ++ ":" ++ file
catObject :: CatFileHandle -> Ref -> IO L.ByteString
catObject h object = CoProcess.query h send receive
where
send to = hPutStrLn to $ show object
send to = do
fileEncoding to
hPutStrLn to $ show object
receive from = do
fileEncoding from
header <- hGetLine from
case words header of
[sha, objtype, size]
@ -56,7 +59,7 @@ catObject h object = CoProcess.query h send receive
| otherwise -> dne
_
| header == show object ++ " missing" -> dne
| otherwise -> error $ "unknown response from git cat-file " ++ header
| otherwise -> error $ "unknown response from git cat-file " ++ show (header, object)
readcontent bytes from = do
content <- S.hGet from bytes
c <- hGetChar from