From d519bc71372fe1962a9e03fc5472f9fe870066f8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 20 Jun 2011 21:35:39 -0400 Subject: sped up git-union-merge Avoided the slow git add, instead inject content directly into git and populate the index all in one pass. Now this runs on my large real-world repo in 10 seconds, which is acceptable. Also lots of code cleanups. --- GitRepo.hs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'GitRepo.hs') diff --git a/GitRepo.hs b/GitRepo.hs index 0bee2842a..9f4a38a5f 100644 --- a/GitRepo.hs +++ b/GitRepo.hs @@ -38,6 +38,8 @@ module GitRepo ( gitCommandLine, run, pipeRead, + pipeWrite, + pipeWriteRead, pipeNullSplit, attributes, remotes, @@ -348,7 +350,7 @@ run repo subcommand params = assertLocal repo $ boolSystem "git" (gitCommandLine repo ((Param subcommand):params)) >>! error $ "git " ++ show params ++ " failed" -{- Runs a git subcommand and returns it output, lazily. +{- Runs a git subcommand and returns its output, lazily. - - Note that this leaves the git process running, and so zombies will - result unless reap is called. @@ -358,6 +360,18 @@ pipeRead repo params = assertLocal repo $ do (_, s) <- pipeFrom "git" $ toCommand $ gitCommandLine repo params return s +{- Runs a git subcommand, feeding it input. + - You should call either getProcessStatus or forceSuccess on the PipeHandle. -} +pipeWrite :: Repo -> [CommandParam] -> String -> IO PipeHandle +pipeWrite repo params s = assertLocal repo $ + pipeTo "git" (toCommand $ gitCommandLine repo params) s + +{- Runs a git subcommand, feeding it input, and returning its output. + - You should call either getProcessStatus or forceSuccess on the PipeHandle. -} +pipeWriteRead :: Repo -> [CommandParam] -> String -> IO (PipeHandle, String) +pipeWriteRead repo params s = assertLocal repo $ + pipeBoth "git" (toCommand $ gitCommandLine repo params) s + {- Reaps any zombie git processes. -} reap :: IO () reap = do -- cgit v1.2.3