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:
parent
93e3c8a09a
commit
dc22549ab3
2 changed files with 14 additions and 5 deletions
|
@ -59,6 +59,9 @@ catObjectDetails h object = CoProcess.query h send receive
|
||||||
hPutStrLn to $ show object
|
hPutStrLn to $ show object
|
||||||
receive from = do
|
receive from = do
|
||||||
fileEncoding from
|
fileEncoding from
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
hSetNewlineMode from noNewlineTranslation
|
||||||
|
#endif
|
||||||
header <- hGetLine from
|
header <- hGetLine from
|
||||||
case words header of
|
case words header of
|
||||||
[sha, objtype, size]
|
[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)
|
| otherwise -> error $ "unknown response from git cat-file " ++ show (header, object)
|
||||||
readcontent bytes from sha = do
|
readcontent bytes from sha = do
|
||||||
content <- S.hGet from bytes
|
content <- S.hGet from bytes
|
||||||
#ifdef __WINDOWS__
|
|
||||||
eatchar '\r' from
|
|
||||||
#endif
|
|
||||||
eatchar '\n' from
|
eatchar '\n' from
|
||||||
return $ Just (L.fromChunks [content], Ref sha)
|
return $ Just (L.fromChunks [content], Ref sha)
|
||||||
dne = return Nothing
|
dne = return Nothing
|
||||||
eatchar expected from = do
|
eatchar expected from = do
|
||||||
c <- hGetChar from
|
c <- hGetChar from
|
||||||
when (c /= expected) $
|
when (c /= expected) $
|
||||||
error $ "missing " ++ (show c) ++ " from git cat-file"
|
error $ "missing " ++ (show expected) ++ " from git cat-file"
|
||||||
|
|
11
Git/HashObject.hs
Normal file → Executable file
11
Git/HashObject.hs
Normal file → Executable file
|
@ -5,6 +5,8 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Git.HashObject where
|
module Git.HashObject where
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
|
@ -32,8 +34,15 @@ hashFile h file = CoProcess.query h send receive
|
||||||
where
|
where
|
||||||
send to = do
|
send to = do
|
||||||
fileEncoding to
|
fileEncoding to
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
hSetNewlineMode to noNewlineTranslation
|
||||||
|
#endif
|
||||||
hPutStrLn to file
|
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. -}
|
{- Injects some content into git, returning its Sha. -}
|
||||||
hashObject :: ObjectType -> String -> Repo -> IO Sha
|
hashObject :: ObjectType -> String -> Repo -> IO Sha
|
||||||
|
|
Loading…
Reference in a new issue