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:
parent
b889581945
commit
00d814aecc
1 changed files with 5 additions and 2 deletions
|
@ -43,8 +43,11 @@ catFile h branch file = catObject h $ Ref $ show branch ++ ":" ++ file
|
||||||
catObject :: CatFileHandle -> Ref -> IO L.ByteString
|
catObject :: CatFileHandle -> Ref -> IO L.ByteString
|
||||||
catObject h object = CoProcess.query h send receive
|
catObject h object = CoProcess.query h send receive
|
||||||
where
|
where
|
||||||
send to = hPutStrLn to $ show object
|
send to = do
|
||||||
|
fileEncoding to
|
||||||
|
hPutStrLn to $ show object
|
||||||
receive from = do
|
receive from = do
|
||||||
|
fileEncoding from
|
||||||
header <- hGetLine from
|
header <- hGetLine from
|
||||||
case words header of
|
case words header of
|
||||||
[sha, objtype, size]
|
[sha, objtype, size]
|
||||||
|
@ -56,7 +59,7 @@ catObject h object = CoProcess.query h send receive
|
||||||
| otherwise -> dne
|
| otherwise -> dne
|
||||||
_
|
_
|
||||||
| header == show object ++ " missing" -> 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
|
readcontent bytes from = do
|
||||||
content <- S.hGet from bytes
|
content <- S.hGet from bytes
|
||||||
c <- hGetChar from
|
c <- hGetChar from
|
||||||
|
|
Loading…
Reference in a new issue