From 00d814aecc7368bbc0fe1722b27340255772d2f2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 26 Feb 2012 14:11:50 -0400 Subject: 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.) --- Git/CatFile.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Git/CatFile.hs b/Git/CatFile.hs index 41ecb362c..c598d7aa4 100644 --- a/Git/CatFile.hs +++ b/Git/CatFile.hs @@ -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 -- cgit v1.2.3