summaryrefslogtreecommitdiff
path: root/Git/Ssh.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Git/Ssh.hs')
-rw-r--r--Git/Ssh.hs22
1 files changed, 14 insertions, 8 deletions
diff --git a/Git/Ssh.hs b/Git/Ssh.hs
index 7d6a305bb..206e72113 100644
--- a/Git/Ssh.hs
+++ b/Git/Ssh.hs
@@ -34,7 +34,10 @@ type SshCommand = String
-- | Checks for GIT_SSH and GIT_SSH_COMMAND and if set, returns
-- a command and parameters to run to ssh.
gitSsh :: SshHost -> Maybe SshPort -> SshCommand -> IO (Maybe (FilePath, [CommandParam]))
-gitSsh host mp cmd = do
+gitSsh host mp cmd = gitSsh' host mp cmd []
+
+gitSsh' :: SshHost -> Maybe SshPort -> SshCommand -> [CommandParam] -> IO (Maybe (FilePath, [CommandParam]))
+gitSsh' host mp cmd extrasshparams = do
gsc <- getEnv gitSshCommandEnv
case gsc of
Just c
@@ -42,24 +45,27 @@ gitSsh host mp cmd = do
-- when it contains spaces; otherwise it's
-- treated the same as GIT_SSH
| any isSpace c -> ret "sh"
- [ [ Param "-c"
- , Param (shellcmd c gitps)
- ]
+ [ Param "-c"
+ , Param (shellcmd c sshps)
]
- | otherwise -> ret c [gitps]
+ | otherwise -> ret c sshps
Nothing -> do
gs <- getEnv gitSshEnv
case gs of
- Just c -> ret c [gitps]
+ Just c -> ret c sshps
Nothing -> return Nothing
where
- ret c ll = return $ Just (c, concat ll)
+ ret c l = return $ Just (c, l)
- -- git passes exactly these parameters to the command
+ -- Git passes exactly these parameters to the ssh command.
gitps = map Param $ case mp of
Nothing -> [host, cmd]
Just p -> [host, "-p", show p, cmd]
+ -- Passing any extra parameters to the ssh command may
+ -- break some commands.
+ sshps = extrasshparams ++ gitps
+
-- The shell command to run with sh -c is constructed
-- this way, rather than using "$@" because there could be some
-- unwanted parameters passed to the command, and this way they