add global fallback for per-repo options
This commit is contained in:
parent
99c522edef
commit
e638f9647d
2 changed files with 15 additions and 9 deletions
19
Remotes.hs
19
Remotes.hs
|
@ -125,7 +125,7 @@ reposByCost l = do
|
||||||
-}
|
-}
|
||||||
repoCost :: Git.Repo -> Annex Int
|
repoCost :: Git.Repo -> Annex Int
|
||||||
repoCost r = do
|
repoCost r = do
|
||||||
cost <- repoConfig r "annex-cost" ""
|
cost <- repoConfig r "cost" ""
|
||||||
if (not $ null cost)
|
if (not $ null cost)
|
||||||
then return $ read cost
|
then return $ read cost
|
||||||
else if (Git.repoIsUrl r)
|
else if (Git.repoIsUrl r)
|
||||||
|
@ -137,7 +137,7 @@ repoCost r = do
|
||||||
- annex-ignore. -}
|
- annex-ignore. -}
|
||||||
repoNotIgnored :: Git.Repo -> Annex Bool
|
repoNotIgnored :: Git.Repo -> Annex Bool
|
||||||
repoNotIgnored r = do
|
repoNotIgnored r = do
|
||||||
ignored <- repoConfig r "annex-ignore" "false"
|
ignored <- repoConfig r "ignore" "false"
|
||||||
fromName <- Annex.flagGet "fromrepository"
|
fromName <- Annex.flagGet "fromrepository"
|
||||||
toName <- Annex.flagGet "torepository"
|
toName <- Annex.flagGet "torepository"
|
||||||
let name = if (not $ null fromName) then fromName else toName
|
let name = if (not $ null fromName) then fromName else toName
|
||||||
|
@ -172,7 +172,7 @@ commandLineRemote = do
|
||||||
- returns the updated git repo. -}
|
- returns the updated git repo. -}
|
||||||
tryGitConfigRead :: Git.Repo -> Annex (Either Git.Repo Git.Repo)
|
tryGitConfigRead :: Git.Repo -> Annex (Either Git.Repo Git.Repo)
|
||||||
tryGitConfigRead r = do
|
tryGitConfigRead r = do
|
||||||
sshoptions <- repoConfig r "annex-ssh-options" ""
|
sshoptions <- repoConfig r "ssh-options" ""
|
||||||
if (Map.null $ Git.configMap r)
|
if (Map.null $ Git.configMap r)
|
||||||
then do
|
then do
|
||||||
-- configRead can fail due to IO error or
|
-- 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.) -}
|
{- Runs scp against a specified remote. (Honors annex-scp-options.) -}
|
||||||
scp :: Git.Repo -> [String] -> Annex Bool
|
scp :: Git.Repo -> [String] -> Annex Bool
|
||||||
scp r params = do
|
scp r params = do
|
||||||
scpoptions <- repoConfig r "annex-scp-options" ""
|
scpoptions <- repoConfig r "scp-options" ""
|
||||||
Core.showProgress -- make way for scp progress bar
|
Core.showProgress -- make way for scp progress bar
|
||||||
liftIO $ boolSystem "scp" $ "-p":(words scpoptions) ++ params
|
liftIO $ boolSystem "scp" $ "-p":(words scpoptions) ++ params
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ scp r params = do
|
||||||
- (Honors annex-ssh-options.) -}
|
- (Honors annex-ssh-options.) -}
|
||||||
runCmd :: Git.Repo -> String -> [String] -> Annex Bool
|
runCmd :: Git.Repo -> String -> [String] -> Annex Bool
|
||||||
runCmd r command params = do
|
runCmd r command params = do
|
||||||
sshoptions <- repoConfig r "annex-ssh-options" ""
|
sshoptions <- repoConfig r "ssh-options" ""
|
||||||
if (not $ Git.repoIsUrl r)
|
if (not $ Git.repoIsUrl r)
|
||||||
then do
|
then do
|
||||||
cwd <- liftIO $ getCurrentDirectory
|
cwd <- liftIO $ getCurrentDirectory
|
||||||
|
@ -253,10 +253,13 @@ runCmd r command params = do
|
||||||
(unwords $ map shellEscape params)]
|
(unwords $ map shellEscape params)]
|
||||||
else error "running command in non-ssh repo not supported"
|
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 :: Git.Repo -> String -> String -> Annex String
|
||||||
repoConfig r key def = do
|
repoConfig r key def = do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
return $ Git.configGet g fullkey def
|
let def' = Git.configGet g global def
|
||||||
|
return $ Git.configGet g local def'
|
||||||
where
|
where
|
||||||
fullkey = "remote." ++ (Git.repoRemoteName r) ++ "." ++ key
|
local = "remote." ++ (Git.repoRemoteName r) ++ ".annex-" ++ key
|
||||||
|
global = "annex." ++ key
|
||||||
|
|
|
@ -178,7 +178,8 @@ Many git-annex subcommands will stage changes for later `git commit` by you.
|
||||||
|
|
||||||
# CONFIGURATION
|
# 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.uuid` -- a unique UUID for this repository (automatically set)
|
||||||
* `annex.numcopies` -- number of copies of files to keep across all
|
* `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"
|
the bandwidth to 100Kbit/s, set it to "-6 -l 100"
|
||||||
* `remote.<name>.annex-ssh-options` -- Options to use when using ssh
|
* `remote.<name>.annex-ssh-options` -- Options to use when using ssh
|
||||||
to talk to this repository.
|
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
|
# FILES
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue