Support scp-style urls for remotes (host:path).

This commit is contained in:
Joey Hess 2010-12-28 13:48:11 -04:00
parent c7344eff81
commit 022e0c7751
3 changed files with 29 additions and 1 deletions

View file

@ -60,6 +60,7 @@ import Data.Char
import Data.Word (Word8)
import Codec.Binary.UTF8.String (encode)
import Text.Printf
import Data.List (isInfixOf)
import Utility
@ -314,8 +315,20 @@ configRemotes repo = map construct remotepairs
isremote k = startswith "remote." k && endswith ".url" k
remotename k = split "." k !! 1
construct (k,v) = (gen v) { remoteName = Just $ remotename k }
gen v | isURI v = repoFromUrl v
gen v | scpstyle v = repoFromUrl $ scptourl v
| isURI v = repoFromUrl v
| otherwise = repoFromPath v
-- git remotes can be written scp style -- [user@]host:dir
-- where dir is relative to the user's home directory.
scpstyle v = isInfixOf ":" v && (not $ isInfixOf "//" v)
scptourl v = "ssh://" ++ host ++ slash dir
where
bits = split ":" v
host = bits !! 0
dir = join ":" $ drop 1 bits
slash d | d == "" = "/~/" ++ dir
| d !! 0 == '/' = dir
| otherwise = "/~/" ++ dir
{- Parses git config --list output into a config map. -}
configParse :: String -> Map.Map String String

6
debian/changelog vendored
View file

@ -1,3 +1,9 @@
git-annex (0.15) UNRELEASED; urgency=low
* Support scp-style urls for remotes (host:path).
-- Joey Hess <joeyh@debian.org> Tue, 28 Dec 2010 13:13:20 -0400
git-annex (0.14) unstable; urgency=low
* Bugfix to git annex unused in a repository with nothing yet annexed.

View file

@ -9,3 +9,12 @@ Specifically, if I have ~/bar set up on host foo:
# url = ssh://foo/~/bar
## this one works
url = ssh://foo/home/tv/bar
> scp-style is now supported.
> `~` expansions (for the user's home, or other users)
> are somewhat tricky to support as they require running
> code on the remote to lookup homedirs. If git-annex grows a
> `git annex shell` that is run on the remote side
> (something I am considering for other reasons), it
> could handle the expansions there. --[[Joey]]