super tricky shell command generation hack
GIT_SSH_COMMAND was not working correctly with git-annex get, because when used in rsync -e, there were additional parameters appended at the end, which the GIT_SSH_COMMAND should not see. Fixed by constructing the shell command differently. This commit was supported by the NSF-funded DataLad project.
This commit is contained in:
parent
c9578be5b2
commit
d674fd5a69
1 changed files with 11 additions and 5 deletions
16
Git/Ssh.hs
16
Git/Ssh.hs
|
@ -43,10 +43,8 @@ gitSsh host mp cmd = do
|
||||||
-- treated the same as GIT_SSH
|
-- treated the same as GIT_SSH
|
||||||
| any isSpace c -> ret "sh"
|
| any isSpace c -> ret "sh"
|
||||||
[ [ Param "-c"
|
[ [ Param "-c"
|
||||||
, Param (c ++ " \"$@\"")
|
, Param (shellcmd c gitps)
|
||||||
, Param c
|
|
||||||
]
|
]
|
||||||
, gitps
|
|
||||||
]
|
]
|
||||||
| otherwise -> ret c [gitps]
|
| otherwise -> ret c [gitps]
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
|
@ -55,8 +53,16 @@ gitSsh host mp cmd = do
|
||||||
Just c -> ret c [gitps]
|
Just c -> ret c [gitps]
|
||||||
Nothing -> return Nothing
|
Nothing -> return Nothing
|
||||||
where
|
where
|
||||||
-- git passes exactly these parameters
|
ret c ll = return $ Just (c, concat ll)
|
||||||
|
|
||||||
|
-- git passes exactly these parameters to the command
|
||||||
gitps = map Param $ case mp of
|
gitps = map Param $ case mp of
|
||||||
Nothing -> [host, cmd]
|
Nothing -> [host, cmd]
|
||||||
Just p -> [host, "-p", show p, cmd]
|
Just p -> [host, "-p", show p, cmd]
|
||||||
ret c ll = return $ Just (c, concat ll)
|
|
||||||
|
-- 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
|
||||||
|
-- are ignored. For example, when Utility.Rsync.rsyncShell is
|
||||||
|
-- used, rsync adds some parameters after the command.
|
||||||
|
shellcmd c ps = c ++ " " ++ unwords (map shellEscape (toCommand ps))
|
||||||
|
|
Loading…
Add table
Reference in a new issue