summaryrefslogtreecommitdiff
path: root/Git/Command.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-08-24 20:50:39 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-08-24 20:50:39 -0400
commitc9b3b8829dc3f106583fb933808179ec02773790 (patch)
treed2b27b5d8ee40c74be33c83807761c5eb5cea584 /Git/Command.hs
parent8de7699f3905f5a3feb88cd6297f982f3666a201 (diff)
thread safe git-annex index file use
Diffstat (limited to 'Git/Command.hs')
-rw-r--r--Git/Command.hs18
1 files changed, 15 insertions, 3 deletions
diff --git a/Git/Command.hs b/Git/Command.hs
index cd6c98d33..04b0723d0 100644
--- a/Git/Command.hs
+++ b/Git/Command.hs
@@ -8,6 +8,7 @@
module Git.Command where
import System.Posix.Process (getAnyProcessStatus)
+import System.Process
import Common
import Git
@@ -26,7 +27,9 @@ gitCommandLine _ repo = assertLocal repo $ error "internal"
{- Runs git in the specified repo. -}
runBool :: String -> [CommandParam] -> Repo -> IO Bool
runBool subcommand params repo = assertLocal repo $
- boolSystem "git" $ gitCommandLine (Param subcommand : params) repo
+ boolSystemEnv "git"
+ (gitCommandLine (Param subcommand : params) repo)
+ (gitEnv repo)
{- Runs git in the specified repo, throwing an error if it fails. -}
run :: String -> [CommandParam] -> Repo -> IO ()
@@ -45,14 +48,23 @@ pipeRead params repo = assertLocal repo $
fileEncoding h
hGetContents h
where
- p = proc "git" $ toCommand $ gitCommandLine params repo
+ p = (proc "git" $ toCommand $ gitCommandLine params repo)
+ { env = gitEnv repo }
{- Runs a git subcommand, feeding it input, and returning its output,
- which is expected to be fairly small, since it's all read into memory
- strictly. -}
pipeWriteRead :: [CommandParam] -> String -> Repo -> IO String
pipeWriteRead params s repo = assertLocal repo $
- writeReadProcess "git" (toCommand $ gitCommandLine params repo) s
+ writeReadProcessEnv "git" (toCommand $ gitCommandLine params repo)
+ (gitEnv repo) s
+
+{- Runs a git subcommand, feeding it input on a handle with an action. -}
+pipeWrite :: [CommandParam] -> Repo -> (Handle -> IO ()) -> IO ()
+pipeWrite params repo = withHandle StdinHandle createProcessSuccess p
+ where
+ p = (proc "git" $ toCommand $ gitCommandLine params repo)
+ { env = gitEnv repo }
{- Reads null terminated output of a git command (as enabled by the -z
- parameter), and splits it. -}