aboutsummaryrefslogtreecommitdiff
path: root/Git/Queue.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-08-01 15:15:49 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-08-01 15:15:49 -0400
commit873054e26ee1a3b64d6fc7132519a0f044fcb523 (patch)
tree5bf5cdfeeaa68ba721d7b18f01618ac588115807 /Git/Queue.hs
parent17d01871b9be30abc69dc2e71891b61daaff4357 (diff)
Escape ':' in file/directory names to avoid it being treated as a pathspec by some git commands
A git pathspec is a filename, except when it starts with ':', it's taken to refer to a branch, etc. Rather than special case ':', any filename starting with anything unusual is prefixed with "./" This could have been a real mess to deal with, but luckily SafeCommand is already extensively used and so we know at the type level the difference between parameters that are files, and parameters that are command options. Testing did show that Git.Queue was not using SafeCommand on filenames fed to xargs. (Filenames starting with '-' worked before only because -- was used to separate filenames from options when calling eg git add.) The test suite now passes with filenames starting with ':'. However, I did not keep that change to it, because such filenames are probably not legal on windows, and I have enough ugly windows ifdefs in there as it is. This commit was sponsored by Otavio Salvador. Thanks!
Diffstat (limited to 'Git/Queue.hs')
-rw-r--r--Git/Queue.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/Git/Queue.hs b/Git/Queue.hs
index d88c71880..b8e863658 100644
--- a/Git/Queue.hs
+++ b/Git/Queue.hs
@@ -40,7 +40,7 @@ data Action
| CommandAction
{ getSubcommand :: String
, getParams :: [CommandParam]
- , getFiles :: [FilePath]
+ , getFiles :: [CommandParam]
}
{- A key that can uniquely represent an action in a Map. -}
@@ -92,7 +92,7 @@ addCommand subcommand params files q repo =
, getParams = params
, getFiles = newfiles
}
- newfiles = files ++ maybe [] getFiles (M.lookup key $ items q)
+ newfiles = map File files ++ maybe [] getFiles (M.lookup key $ items q)
different (CommandAction { getSubcommand = s }) = s /= subcommand
different _ = True
@@ -150,7 +150,7 @@ runAction repo (UpdateIndexAction streamers) =
runAction repo action@(CommandAction {}) =
withHandle StdinHandle createProcessSuccess p $ \h -> do
fileEncoding h
- hPutStr h $ intercalate "\0" $ getFiles action
+ hPutStr h $ intercalate "\0" $ toCommand $ getFiles action
hClose h
where
p = (proc "xargs" params) { env = gitEnv repo }