diff options
author | Joey Hess <joey@kitenet.net> | 2012-07-19 00:43:36 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-07-19 00:46:52 -0400 |
commit | 1db7d27a451f552dbae8760e83c73b90da8114d5 (patch) | |
tree | 69beba839e2c996658133679c6aca3be40b4f9f6 /Git/Command.hs | |
parent | 549f8619998eab17aaf2122f11f036fac7e6cc40 (diff) |
add back debug logging
Make Utility.Process wrap the parts of System.Process that I use,
and add debug logging to them.
Also wrote some higher-level code that allows running an action
with handles to a processes stdin or stdout (or both), and checking
its exit status, all in a single function call.
As a bonus, the debug logging now indicates whether the process
is being run to read from it, feed it data, chat with it (writing and
reading), or just call it for its side effect.
Diffstat (limited to 'Git/Command.hs')
-rw-r--r-- | Git/Command.hs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Git/Command.hs b/Git/Command.hs index 038824f26..d7c983064 100644 --- a/Git/Command.hs +++ b/Git/Command.hs @@ -7,7 +7,6 @@ module Git.Command where -import System.Process import System.Posix.Process (getAnyProcessStatus) import Common @@ -41,12 +40,12 @@ run subcommand params repo = assertLocal repo $ - result unless reap is called. -} pipeRead :: [CommandParam] -> Repo -> IO String -pipeRead params repo = assertLocal repo $ do - (_, Just h, _, _) <- createProcess - (proc "git" $ toCommand $ gitCommandLine params repo) - { std_out = CreatePipe } - fileEncoding h - hGetContents h +pipeRead params repo = assertLocal repo $ + withHandle StdoutHandle createBackgroundProcess p $ \h -> do + fileEncoding h + hGetContents h + where + p = proc "git" $ toCommand $ gitCommandLine params 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 |