summaryrefslogtreecommitdiff
path: root/GitQueue.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-27 13:12:02 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-27 13:12:02 -0400
commit5b4fa4aeca9c67dc1d40dee9782a4806d7702b4c (patch)
treeff1b3b9e75af0a3360d4754ad046fad98f448ef3 /GitQueue.hs
parent24ee4439d4783cde7102f4ffd857c521367ce16f (diff)
use xargs
Diffstat (limited to 'GitQueue.hs')
-rw-r--r--GitQueue.hs28
1 files changed, 11 insertions, 17 deletions
diff --git a/GitQueue.hs b/GitQueue.hs
index b7210ccb5..34a89f17b 100644
--- a/GitQueue.hs
+++ b/GitQueue.hs
@@ -1,4 +1,4 @@
-{- git repository command queues
+{- git repository command queue
-}
module GitQueue (
@@ -9,6 +9,9 @@ module GitQueue (
) where
import qualified Data.Map as M
+import System.IO
+import System.Cmd.Utils
+import Data.String.Utils
import qualified GitRepo as Git
@@ -45,20 +48,11 @@ run repo queue = do
- Complicated by commandline length limits. -}
runAction :: Git.Repo -> Action -> [FilePath] -> IO ()
runAction repo action files = do
- xargs [] 0 files
+ if (null files)
+ then return ()
+ else runxargs
where
- arg_max = 2048 -- TODO get better ARG_MAX
- maxlen = arg_max - cmdlen
- c = (subcommand action):(params action)
- cmdlen = (length "git") +
- (foldl (\a b -> a + b + 1) 1 $ map length c)
- xargs collect _ [] = exec collect
- xargs collect len (f:fs) = do
- let len' = len + 1 + length f
- if (len' >= maxlen)
- then do
- exec collect
- xargs [f] (length f) fs
- else xargs (f:collect) len' fs
- exec [] = return ()
- exec fs = Git.run repo $ c ++ fs
+ runxargs = pOpen WriteToPipe "xargs"
+ (["-0", "git", subcommand action] ++ (params action))
+ feedxargs
+ feedxargs h = hPutStr h $ join "\0" files