Added remote.annex-scp-options and remote.annex-ssh-options.

This commit is contained in:
Joey Hess 2010-10-31 22:56:56 -04:00
parent e70812eca9
commit 0194394be6
3 changed files with 34 additions and 21 deletions

View file

@ -115,33 +115,28 @@ reposByCost l = do
-}
repoCost :: Git.Repo -> Annex Int
repoCost r = do
g <- Annex.gitRepo
if (not $ null $ config g)
then return $ read $ config g
cost <- repoConfig r "annex-cost" ""
if (not $ null cost)
then return $ read cost
else if (Git.repoIsUrl r)
then return 200
else return 100
where
config g = Git.configGet g configkey ""
configkey = "remote." ++ (Git.repoRemoteName r) ++ ".annex-cost"
{- Checks if a repo should be ignored, based either on annex-ignore
- setting, or on command-line options. Allows command-line to override
- annex-ignore. -}
repoNotIgnored :: Git.Repo -> Annex Bool
repoNotIgnored r = do
g <- Annex.gitRepo
ignored <- repoConfig r "annex-ignore" "false"
fromName <- Annex.flagGet "fromrepository"
toName <- Annex.flagGet "torepository"
let name = if (not $ null fromName) then fromName else toName
if (not $ null name)
then return $ match name
else return $ not $ ignored g
else return $ not $ isIgnored ignored
where
match name = name == Git.repoRemoteName r
ignored g = Git.configTrue $ config g
config g = Git.configGet g configkey ""
configkey = "remote." ++ (Git.repoRemoteName r) ++ ".annex-ignore"
isIgnored ignored = Git.configTrue ignored
{- Returns the remote specified by --from or --to, may fail with error. -}
commandLineRemote :: Annex Git.Repo
@ -195,8 +190,7 @@ copyFromRemote r key file = do
else error "copying from non-ssh repo not supported"
where
getlocal = liftIO $ boolSystem "cp" ["-a", keyloc, file]
getssh = do
scp [sshLocation r keyloc, file]
getssh = scp r [sshLocation r keyloc, file]
keyloc = annexLocation r key
{- Tries to copy a key's content to a file on a remote. -}
@ -211,20 +205,23 @@ copyToRemote r key file = do
else error "copying to non-ssh repo not supported"
where
putlocal src = liftIO $ boolSystem "cp" ["-a", src, file]
putssh src = do
scp [src, sshLocation r file]
putssh src = scp r [src, sshLocation r file]
sshLocation :: Git.Repo -> FilePath -> FilePath
sshLocation r file = (Git.urlHost r) ++ ":" ++ shellEscape file
scp :: [String] -> Annex Bool
scp params = do
{- Runs scp against a specified remote. (Honors annex-scp-options.) -}
scp :: Git.Repo -> [String] -> Annex Bool
scp r params = do
scpoptions <- repoConfig r "annex-scp-options" ""
Core.showProgress -- make way for scp progress bar
liftIO $ boolSystem "scp" ("-p":params)
liftIO $ boolSystem "scp" $ "-p":(words scpoptions) ++ params
{- Runs a command in a remote. -}
{- Runs a command in a remote, using ssh if necessary.
- (Honors annex-ssh-options.) -}
runCmd :: Git.Repo -> String -> [String] -> Annex Bool
runCmd r command params = do
sshoptions <- repoConfig r "annex-ssh-options" ""
if (not $ Git.repoIsUrl r)
then do
cwd <- liftIO $ getCurrentDirectory
@ -233,8 +230,18 @@ runCmd r command params = do
boolSystem command params
else if (Git.repoIsSsh r)
then do
liftIO $ boolSystem "ssh" [Git.urlHost r,
"cd " ++ (shellEscape $ Git.workTree r) ++
liftIO $ boolSystem "ssh" $
(words sshoptions) ++
[Git.urlHost r, "cd " ++
(shellEscape $ Git.workTree r) ++
" && " ++ (shellEscape command) ++ " " ++
(unwords $ map shellEscape params)]
else error "running command in non-ssh repo not supported"
{- Looks up a per-remote config option in git config. -}
repoConfig :: Git.Repo -> String -> String -> Annex String
repoConfig r key def = do
g <- Annex.gitRepo
return $ Git.configGet g fullkey def
where
fullkey = "remote." ++ (Git.repoRemoteName r) ++ "." ++ key

1
debian/changelog vendored
View file

@ -8,6 +8,7 @@ git-annex (0.03) UNRELEASED; urgency=low
* Fixed memory leak; git-annex no longer reads the whole file list
from git before starting, and will be much faster with large repos.
* Fix crash on unknown symlinks.
* Added remote.annex-scp-options and remote.annex-ssh-options.
-- Joey Hess <joeyh@debian.org> Thu, 28 Oct 2010 13:46:59 -0400

View file

@ -196,6 +196,11 @@ Like other git commands, git-annex is configured via `.git/config`.
from ever using this remote.
* `remote.<name>.annex-uuid` -- git-annex caches UUIDs of repositories
here.
* `remote.<name>.annex-scp-options` -- Options to use when using scp
to or from this repository. For example, to force ipv6, and limit
the bandwidth to 100Kbit/s, set it to "-6 -l 100"
* `remote.<name>.annex-ssh-options` -- Options to use when using ssh
to talk to this repository.
# FILES