summaryrefslogtreecommitdiff
path: root/Git/CatFile.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <id@joeyh.name>2013-05-11 15:32:34 -0500
committerGravatar Joey Hess <id@joeyh.name>2013-05-11 15:32:34 -0500
commit4f4d997119aad64655283b3e70c8ee9d9a6c5fdf (patch)
treeccec00019a7c9cd908e51560acf5695ab122ccce /Git/CatFile.hs
parentd0fa82fb721cdc85438287e29a94cb796b7bc464 (diff)
catFile expects no \r, even on Windows
Diffstat (limited to 'Git/CatFile.hs')
-rwxr-xr-x[-rw-r--r--]Git/CatFile.hs16
1 files changed, 13 insertions, 3 deletions
diff --git a/Git/CatFile.hs b/Git/CatFile.hs
index 704724211..88011f071 100644..100755
--- a/Git/CatFile.hs
+++ b/Git/CatFile.hs
@@ -5,6 +5,8 @@
- Licensed under the GNU GPL version 3 or higher.
-}
+{-# LANGUAGE CPP #-}
+
module Git.CatFile (
CatFileHandle,
catFileStart,
@@ -51,6 +53,9 @@ catObjectDetails h object = CoProcess.query h send receive
where
send to = do
fileEncoding to
+#ifdef __WINDOWS__
+ hSetNewlineMode to noNewlineTranslation
+#endif
hPutStrLn to $ show object
receive from = do
fileEncoding from
@@ -68,8 +73,13 @@ catObjectDetails h object = CoProcess.query h send receive
| 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"
+#ifdef __WINDOWS__
+ eatchar '\r' from
+#endif
+ eatchar '\n' from
return $ Just (L.fromChunks [content], Ref sha)
dne = return Nothing
+ eatchar expected from = do
+ c <- hGetChar from
+ when (c /= expected) $
+ error $ "missing " ++ (show c) ++ " from git cat-file"