annexInsteadOf config
Added config `url.<base>.annexInsteadOf` corresponding to git's `url.<base>.pushInsteadOf`, to configure the urls to use for accessing the git-annex repositories on a server without needing to configure remote.name.annexUrl in each repository. While one use case for this would be rewriting urls to use annex+http, I decided not to add any kind of special case for that. So while git-annex p2phttp, when serving multiple repositories, needs an url of eg "annex+http://example.com/git-annex/ for each of them, rewriting an url like "https://example.com/git/foo/bar" with this config set to "https://example.com/git/" will result in eg "annex+http://example.com/git-annex/foo/bar", which p2phttp does not support. That seems better dealt with in either git-annex p2phttp or a http middleware, rather than complicating the config with a special case for annex+http. Anyway, there are other use cases for this that don't involve annex+http.
This commit is contained in:
parent
0404968d10
commit
dd052dcba1
7 changed files with 79 additions and 41 deletions
|
@ -27,6 +27,7 @@ module Types.GitConfig (
|
|||
proxyInheritedFields,
|
||||
MkRemoteConfigKey,
|
||||
mkRemoteConfigKey,
|
||||
annexInsteadOfUrl,
|
||||
) where
|
||||
|
||||
import Common
|
||||
|
@ -35,7 +36,7 @@ import qualified Git.Config
|
|||
import qualified Git.Construct
|
||||
import Git.Types
|
||||
import Git.ConfigTypes
|
||||
import Git.Remote (isRemoteKey, isLegalName, remoteKeyToRemoteName)
|
||||
import Git.Remote (isRemoteKey, isLegalName, remoteKeyToRemoteName, insteadOfUrl)
|
||||
import Git.Branch (CommitMode(..))
|
||||
import Git.Quote (QuotePath(..))
|
||||
import Utility.DataUnits
|
||||
|
@ -497,16 +498,14 @@ extractRemoteGitConfig r remotename = do
|
|||
, remoteAnnexClusterGateway = fromMaybe [] $
|
||||
(mapMaybe (mkClusterUUID . toUUID) . words)
|
||||
<$> getmaybe ClusterGatewayField
|
||||
, remoteUrl = case Git.Config.getMaybe (mkRemoteConfigKey remotename (remoteGitConfigKey UrlField)) r of
|
||||
Just (ConfigValue b)
|
||||
| B.null b -> Nothing
|
||||
| otherwise -> Just (decodeBS b)
|
||||
_ -> Nothing
|
||||
, remoteUrl = getremoteurl
|
||||
, remoteAnnexP2PHttpUrl =
|
||||
case Git.Config.getMaybe (mkRemoteConfigKey remotename (remoteGitConfigKey AnnexUrlField)) r of
|
||||
Just (ConfigValue b) ->
|
||||
parseP2PHttpUrl (decodeBS b)
|
||||
_ -> Nothing
|
||||
_ -> parseP2PHttpUrl
|
||||
=<< annexInsteadOfUrl (fullconfig r)
|
||||
=<< getremoteurl
|
||||
, remoteAnnexShell = getmaybe ShellField
|
||||
, remoteAnnexSshOptions = getoptions SshOptionsField
|
||||
, remoteAnnexRsyncOptions = getoptions RsyncOptionsField
|
||||
|
@ -544,6 +543,11 @@ extractRemoteGitConfig r remotename = do
|
|||
in Git.Config.getMaybe (mkRemoteConfigKey remotename k) r
|
||||
<|> Git.Config.getMaybe (mkAnnexConfigKey k) r
|
||||
getoptions k = fromMaybe [] $ words <$> getmaybe k
|
||||
getremoteurl = case Git.Config.getMaybe (mkRemoteConfigKey remotename (remoteGitConfigKey UrlField)) r of
|
||||
Just (ConfigValue b)
|
||||
| B.null b -> Nothing
|
||||
| otherwise -> Just (decodeBS b)
|
||||
_ -> Nothing
|
||||
|
||||
data RemoteGitConfigField
|
||||
= CostField
|
||||
|
@ -742,3 +746,6 @@ remoteAnnexConfigEnd key = "annex-" <> key
|
|||
remoteConfig :: RemoteNameable r => r -> B.ByteString -> ConfigKey
|
||||
remoteConfig r key = ConfigKey $
|
||||
"remote." <> encodeBS (getRemoteName r) <> "." <> key
|
||||
|
||||
annexInsteadOfUrl :: RepoFullConfig -> String -> Maybe String
|
||||
annexInsteadOfUrl fullcfg loc = insteadOfUrl loc ".annexinsteadof" fullcfg
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue