git annex init works on Windows!

git hash-object and cat-file both only use \n at ends of line, even on Windows.
This commit is contained in:
Joey Hess 2013-05-11 16:02:35 -05:00
parent 93e3c8a09a
commit dc22549ab3
2 changed files with 14 additions and 5 deletions

11
Git/HashObject.hs Normal file → Executable file
View file

@ -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