From 022e0c7751db23805169c5429851903a3d482cb2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 28 Dec 2010 13:48:11 -0400 Subject: [PATCH] Support scp-style urls for remotes (host:path). --- GitRepo.hs | 15 ++++++++++++++- debian/changelog | 6 ++++++ .../wishlist:_support_for_more_ssh_urls_.mdwn | 9 +++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/GitRepo.hs b/GitRepo.hs index 122b5cc60f..2c2ad7b539 100644 --- a/GitRepo.hs +++ b/GitRepo.hs @@ -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 diff --git a/debian/changelog b/debian/changelog index f8a3c3129d..dba343deff 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +git-annex (0.15) UNRELEASED; urgency=low + + * Support scp-style urls for remotes (host:path). + + -- Joey Hess 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. diff --git a/doc/bugs/wishlist:_support_for_more_ssh_urls_.mdwn b/doc/bugs/wishlist:_support_for_more_ssh_urls_.mdwn index 42107e51a3..6156ade054 100644 --- a/doc/bugs/wishlist:_support_for_more_ssh_urls_.mdwn +++ b/doc/bugs/wishlist:_support_for_more_ssh_urls_.mdwn @@ -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]]