aboutsummaryrefslogtreecommitdiff
path: root/Git/Command.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-02-01 16:05:02 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-02-01 16:16:08 -0400
commit3d49258e5bed4d9a6ec9e24ddb776f277542664b (patch)
tree89af32cbdde6a5e672c357c24fe281337e2a133a /Git/Command.hs
parent6c64a214fa569dcf1fa8cc4c79efd90d01ff5705 (diff)
attempt at a quick, utf-8 only fix to the ghc 7.4 problem
If you have only utf-8 filenames, and need to build git-annex with ghc 7.4, this will work. But, it will crash on non-utf-8 filenames.
Diffstat (limited to 'Git/Command.hs')
-rw-r--r--Git/Command.hs26
1 files changed, 15 insertions, 11 deletions
diff --git a/Git/Command.hs b/Git/Command.hs
index ec701c1f0..1650efe13 100644
--- a/Git/Command.hs
+++ b/Git/Command.hs
@@ -7,7 +7,10 @@
module Git.Command where
-import qualified Data.ByteString.Lazy.Char8 as L
+import qualified Data.Text.Lazy as L
+import qualified Data.Text.Lazy.Encoding as L
+import qualified Data.Text.Lazy.IO as L
+import qualified Data.ByteString.Lazy as B
import Common
import Git
@@ -38,28 +41,27 @@ run subcommand params repo = assertLocal repo $
- Note that this leaves the git process running, and so zombies will
- result unless reap is called.
-}
-pipeRead :: [CommandParam] -> Repo -> IO L.ByteString
+pipeRead :: [CommandParam] -> Repo -> IO L.Text
pipeRead params repo = assertLocal repo $ do
(_, h) <- hPipeFrom "git" $ toCommand $ gitCommandLine params repo
- hSetBinaryMode h True
- L.hGetContents h
+ L.decodeUtf8 <$> B.hGetContents h
{- Runs a git subcommand, feeding it input.
- You should call either getProcessStatus or forceSuccess on the PipeHandle. -}
-pipeWrite :: [CommandParam] -> L.ByteString -> Repo -> IO PipeHandle
+pipeWrite :: [CommandParam] -> L.Text -> Repo -> IO PipeHandle
pipeWrite params s repo = assertLocal repo $ do
(p, h) <- hPipeTo "git" (toCommand $ gitCommandLine params repo)
- L.hPut h s
+ L.hPutStr h s
hClose h
return p
{- Runs a git subcommand, feeding it input, and returning its output.
- You should call either getProcessStatus or forceSuccess on the PipeHandle. -}
-pipeWriteRead :: [CommandParam] -> L.ByteString -> Repo -> IO (PipeHandle, L.ByteString)
+pipeWriteRead :: [CommandParam] -> L.Text -> Repo -> IO (PipeHandle, L.Text)
pipeWriteRead params s repo = assertLocal repo $ do
(p, from, to) <- hPipeBoth "git" (toCommand $ gitCommandLine params repo)
hSetBinaryMode from True
- L.hPut to s
+ L.hPutStr to s
hClose to
c <- L.hGetContents from
return (p, c)
@@ -67,12 +69,14 @@ pipeWriteRead params s repo = assertLocal repo $ do
{- Reads null terminated output of a git command (as enabled by the -z
- parameter), and splits it. -}
pipeNullSplit :: [CommandParam] -> Repo -> IO [String]
-pipeNullSplit params repo = map L.unpack <$> pipeNullSplitB params repo
+pipeNullSplit params repo = map L.unpack <$> pipeNullSplitT params repo
{- For when Strings are not needed. -}
-pipeNullSplitB ::[CommandParam] -> Repo -> IO [L.ByteString]
-pipeNullSplitB params repo = filter (not . L.null) . L.split '\0' <$>
+pipeNullSplitT ::[CommandParam] -> Repo -> IO [L.Text]
+pipeNullSplitT params repo = filter (not . L.null) . L.splitOn sep <$>
pipeRead params repo
+ where
+ sep = L.pack "\0"
{- Reaps any zombie git processes. -}
reap :: IO ()