From 19ba07456f14db4aacf41be18673a06c9a04fa17 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 11 May 2013 16:02:35 -0500 Subject: git annex init works on Windows! git hash-object and cat-file both only use \n at ends of line, even on Windows. --- Git/CatFile.hs | 8 ++++---- Git/HashObject.hs | 11 ++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) mode change 100644 => 100755 Git/HashObject.hs (limited to 'Git') diff --git a/Git/CatFile.hs b/Git/CatFile.hs index 88011f071..c1ba11bd9 100755 --- a/Git/CatFile.hs +++ b/Git/CatFile.hs @@ -59,6 +59,9 @@ catObjectDetails h object = CoProcess.query h send receive hPutStrLn to $ show object receive from = do fileEncoding from +#ifdef __WINDOWS__ + hSetNewlineMode from noNewlineTranslation +#endif header <- hGetLine from case words header of [sha, objtype, size] @@ -73,13 +76,10 @@ 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 -#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" + error $ "missing " ++ (show expected) ++ " from git cat-file" diff --git a/Git/HashObject.hs b/Git/HashObject.hs old mode 100644 new mode 100755 index b4a32ef1c..5e153687d --- a/Git/HashObject.hs +++ b/Git/HashObject.hs @@ -5,6 +5,8 @@ - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Git.HashObject where import Common @@ -32,8 +34,15 @@ hashFile h file = CoProcess.query h send receive where send to = do fileEncoding to +#ifdef __WINDOWS__ + hSetNewlineMode to noNewlineTranslation +#endif hPutStrLn to file - receive from = getSha "hash-object" $ hGetLine from + receive from = getSha "hash-object" $ do +#ifdef __WINDOWS__ + hSetNewlineMode from noNewlineTranslation +#endif + hGetLine from {- Injects some content into git, returning its Sha. -} hashObject :: ObjectType -> String -> Repo -> IO Sha -- cgit v1.2.3