add global fallback for per-repo options

This commit is contained in:
Joey Hess 2010-11-01 00:17:26 -04:00
parent 99c522edef
commit e638f9647d
2 changed files with 15 additions and 9 deletions

View file

@ -125,7 +125,7 @@ reposByCost l = do
-}
repoCost :: Git.Repo -> Annex Int
repoCost r = do
cost <- repoConfig r "annex-cost" ""
cost <- repoConfig r "cost" ""
if (not $ null cost)
then return $ read cost
else if (Git.repoIsUrl r)
@ -137,7 +137,7 @@ repoCost r = do
- annex-ignore. -}
repoNotIgnored :: Git.Repo -> Annex Bool
repoNotIgnored r = do
ignored <- repoConfig r "annex-ignore" "false"
ignored <- repoConfig r "ignore" "false"
fromName <- Annex.flagGet "fromrepository"
toName <- Annex.flagGet "torepository"
let name = if (not $ null fromName) then fromName else toName
@ -172,7 +172,7 @@ commandLineRemote = do
- returns the updated git repo. -}
tryGitConfigRead :: Git.Repo -> Annex (Either Git.Repo Git.Repo)
tryGitConfigRead r = do
sshoptions <- repoConfig r "annex-ssh-options" ""
sshoptions <- repoConfig r "ssh-options" ""
if (Map.null $ Git.configMap r)
then do
-- configRead can fail due to IO error or
@ -228,7 +228,7 @@ sshLocation r file = (Git.urlHost r) ++ ":" ++ shellEscape file
{- 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" ""
scpoptions <- repoConfig r "scp-options" ""
Core.showProgress -- make way for scp progress bar
liftIO $ boolSystem "scp" $ "-p":(words scpoptions) ++ params
@ -236,7 +236,7 @@ scp r params = do
- (Honors annex-ssh-options.) -}
runCmd :: Git.Repo -> String -> [String] -> Annex Bool
runCmd r command params = do
sshoptions <- repoConfig r "annex-ssh-options" ""
sshoptions <- repoConfig r "ssh-options" ""
if (not $ Git.repoIsUrl r)
then do
cwd <- liftIO $ getCurrentDirectory
@ -253,10 +253,13 @@ runCmd r command params = do
(unwords $ map shellEscape params)]
else error "running command in non-ssh repo not supported"
{- Looks up a per-remote config option in git config. -}
{- Looks up a per-remote config option in git config.
- Failing that, tries looking for a global config option. -}
repoConfig :: Git.Repo -> String -> String -> Annex String
repoConfig r key def = do
g <- Annex.gitRepo
return $ Git.configGet g fullkey def
let def' = Git.configGet g global def
return $ Git.configGet g local def'
where
fullkey = "remote." ++ (Git.repoRemoteName r) ++ "." ++ key
local = "remote." ++ (Git.repoRemoteName r) ++ ".annex-" ++ key
global = "annex." ++ key

View file

@ -178,7 +178,8 @@ Many git-annex subcommands will stage changes for later `git commit` by you.
# CONFIGURATION
Like other git commands, git-annex is configured via `.git/config`.
Like other git commands, git-annex is configured via `git-config`.
Here are all the supported configuration settings.
* `annex.uuid` -- a unique UUID for this repository (automatically set)
* `annex.numcopies` -- number of copies of files to keep across all
@ -201,6 +202,8 @@ Like other git commands, git-annex is configured via `.git/config`.
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.
* `annex.scp-options` and `annex.ssh-options` -- Default scp and ssh
options to use if a remote does not have specific options.
# FILES