summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-12-28 13:48:11 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-12-28 13:48:11 -0400
commit022e0c7751db23805169c5429851903a3d482cb2 (patch)
tree99cbcf343fdc028aad2e3c5d5a83834070c97e03
parentc7344eff81c7de4f303097816ef26cc74146588a (diff)
Support scp-style urls for remotes (host:path).
-rw-r--r--GitRepo.hs15
-rw-r--r--debian/changelog6
-rw-r--r--doc/bugs/wishlist:_support_for_more_ssh_urls_.mdwn9
3 files changed, 29 insertions, 1 deletions
diff --git a/GitRepo.hs b/GitRepo.hs
index 122b5cc60..2c2ad7b53 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 f8a3c3129..dba343def 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 <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.
diff --git a/doc/bugs/wishlist:_support_for_more_ssh_urls_.mdwn b/doc/bugs/wishlist:_support_for_more_ssh_urls_.mdwn
index 42107e51a..6156ade05 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]]