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:
Joey Hess 2024-12-03 14:01:35 -04:00
parent 0404968d10
commit dd052dcba1
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
7 changed files with 79 additions and 41 deletions

View file

@ -1572,10 +1572,25 @@ Remotes are configured using these settings in `.git/config`.
When this and the `remote.<name>.url` contain the same hostname,
and this is an annex+http(s) url, and that is also a http(s) url,
git-annex assumes that the same username and password can be used
for both urls. When password cacheing is configured, this allows
for both urls. When password caching is configured, this allows
you to only be prompted once for a password when using both git and
git-annex. See gitcredentials(7) for how to set up password caching.
* `url.<base>.annexInsteadOf`
This works similarly to git's `url.<base>.pushInsteadOf`, rewriting
a remote url that starts with the value of this config to instead
start with `<base>`.
The rewritten url is used by git-annex for accessing the remote,
and works the same as `remote.<name>.annexUrl`, including supporting
annex+http urls.
Note that git-annex also supports git's `url.<base>.insteadOf`
configuration. When both are set, the remote's url is first rewritten
by insteadOf, and that rewritten url can then be further
rewritten using annexInsteadOf.
* `remote.<name>.annex-uuid`
git-annex caches UUIDs of remote repositories here.

View file

@ -10,11 +10,14 @@ The same way `remote.<name>.annexUrl` corresponds to
`remote.<name>.pushUrl`.
You would need to set 2 configs, but the separation is clear.
And you could do it once in your global git config for whatever
And you could set it once in your global git config for whatever
servers you commonly use.
Another benefit to is that the new `git-annex p2phttp` server
needs annexUrl to be configured to a different url than the git url
when using it. annexInsteadOf would let that be configured a
single time for all urls on a given git server.
Update: Implemented that. Let me know if you think it solves your problem
well enough.
"""]]