summaryrefslogtreecommitdiff
path: root/GitQueue.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-02-28 16:10:16 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-02-28 16:18:55 -0400
commitfcdc4797a9ab2b792a9bb20f2ca9802b8f6d5a1e (patch)
tree0471848c11df7c1481d8c735eab1280d7684eddc /GitQueue.hs
parent7e5678bcf7cd78bd04520117201be37dc9d4d544 (diff)
use ShellParam type
So, I have a type checked safe handling of filenames starting with dashes, throughout the code.
Diffstat (limited to 'GitQueue.hs')
-rw-r--r--GitQueue.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/GitQueue.hs b/GitQueue.hs
index 4a777af4d..328243fa0 100644
--- a/GitQueue.hs
+++ b/GitQueue.hs
@@ -17,6 +17,7 @@ import System.IO
import System.Cmd.Utils
import Data.String.Utils
import Control.Monad (unless, forM_)
+import Utility
import qualified GitRepo as Git
@@ -24,7 +25,7 @@ import qualified GitRepo as Git
- is not included, and must be able to be appended after the params. -}
data Action = Action {
getSubcommand :: String,
- getParams :: [String]
+ getParams :: [ShellParam]
} deriving (Show, Eq, Ord)
{- A queue of actions to perform (in any order) on a git repository,
@@ -37,7 +38,7 @@ empty :: Queue
empty = M.empty
{- Adds an action to a queue. -}
-add :: Queue -> String -> [String] -> FilePath -> Queue
+add :: Queue -> String -> [ShellParam] -> FilePath -> Queue
add queue subcommand params file = M.insertWith (++) action [file] queue
where
action = Action subcommand params
@@ -55,7 +56,7 @@ runAction :: Git.Repo -> Action -> [FilePath] -> IO ()
runAction repo action files = do
unless (null files) runxargs
where
- runxargs = pOpen WriteToPipe "xargs" ("-0":gitcmd) feedxargs
- gitcmd = "git" : Git.gitCommandLine repo
- (getSubcommand action:getParams action)
+ runxargs = pOpen WriteToPipe "xargs" ("-0":"git":params) feedxargs
+ params = toShell $ Git.gitCommandLine repo
+ (Param (getSubcommand action):getParams action)
feedxargs h = hPutStr h $ join "\0" files