Support scp-style urls for remotes (host:path).
This commit is contained in:
parent
c7344eff81
commit
022e0c7751
3 changed files with 29 additions and 1 deletions
15
GitRepo.hs
15
GitRepo.hs
|
@ -60,6 +60,7 @@ import Data.Char
|
||||||
import Data.Word (Word8)
|
import Data.Word (Word8)
|
||||||
import Codec.Binary.UTF8.String (encode)
|
import Codec.Binary.UTF8.String (encode)
|
||||||
import Text.Printf
|
import Text.Printf
|
||||||
|
import Data.List (isInfixOf)
|
||||||
|
|
||||||
import Utility
|
import Utility
|
||||||
|
|
||||||
|
@ -314,8 +315,20 @@ configRemotes repo = map construct remotepairs
|
||||||
isremote k = startswith "remote." k && endswith ".url" k
|
isremote k = startswith "remote." k && endswith ".url" k
|
||||||
remotename k = split "." k !! 1
|
remotename k = split "." k !! 1
|
||||||
construct (k,v) = (gen v) { remoteName = Just $ remotename k }
|
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
|
| 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. -}
|
{- Parses git config --list output into a config map. -}
|
||||||
configParse :: String -> Map.Map String String
|
configParse :: String -> Map.Map String String
|
||||||
|
|
6
debian/changelog
vendored
6
debian/changelog
vendored
|
@ -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
|
git-annex (0.14) unstable; urgency=low
|
||||||
|
|
||||||
* Bugfix to git annex unused in a repository with nothing yet annexed.
|
* Bugfix to git annex unused in a repository with nothing yet annexed.
|
||||||
|
|
|
@ -9,3 +9,12 @@ Specifically, if I have ~/bar set up on host foo:
|
||||||
# url = ssh://foo/~/bar
|
# url = ssh://foo/~/bar
|
||||||
## this one works
|
## this one works
|
||||||
url = ssh://foo/home/tv/bar
|
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]]
|
||||||
|
|
Loading…
Reference in a new issue