From 71b216d1fb2d2308c75ba0da62e6e6a85c5adb19 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 11 Nov 2011 16:18:41 -0400 Subject: map: Support remotes with /~/ and /~user/ More accurately, it was supported already when map uses git-annex-shell, but not when it does not. Note that the user name cannot be shell escaped using git-annex's current approach for shell escaping. I tried and some shells like dash cannot cd ~'joey'. Rest of directory is still shell escaped, not for security but in case a directory has a space or other weird character. --- Command/Map.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Command') diff --git a/Command/Map.hs b/Command/Map.hs index f72cb107a..8755bc7c2 100644 --- a/Command/Map.hs +++ b/Command/Map.hs @@ -195,11 +195,17 @@ tryScan r configlist = onRemote r (pipedconfig, Nothing) "configlist" [] manualconfiglist = do - let sshcmd = - "cd " ++ shellEscape(Git.workTree r) ++ " && " ++ - "git config --list" sshparams <- sshToRepo r [Param sshcmd] liftIO $ pipedconfig "ssh" sshparams + where + sshcmd = cddir ++ " && " ++ + "git config --list" + dir = Git.workTree r + cddir + | take 2 dir == "/~" = + let (userhome, reldir) = span (/= '/') (drop 1 dir) + in "cd " ++ userhome ++ " && cd " ++ shellEscape (drop 1 reldir) + | otherwise = "cd " ++ shellEscape dir -- First, try sshing and running git config manually, -- only fall back to git-annex-shell configlist if that -- cgit v1.2.3