diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2021-08-29 22:53:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-29 22:53:28 -0400 |
| commit | 16a2e6676f531ae3948036b4d3af39e3a27fd0c8 (patch) | |
| tree | 62cfa74e03dc22a8136639d1e2e004a6a30aa6e1 /include/git2 | |
| parent | 9f84003c229691454e7cb5b90667c180f2658e15 (diff) | |
| parent | 7442c000d95faffd9a2f44d5822101525eb8d0d9 (diff) | |
| download | libgit2-16a2e6676f531ae3948036b4d3af39e3a27fd0c8.tar.gz | |
Merge pull request #6012 from libgit2/ethomson/custom_url
remote: introduce remote_ready_cb, deprecate resolve_url callback
Diffstat (limited to 'include/git2')
| -rw-r--r-- | include/git2/remote.h | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/include/git2/remote.h b/include/git2/remote.h index 5d7a5367d..1f52fcd94 100644 --- a/include/git2/remote.h +++ b/include/git2/remote.h @@ -212,7 +212,8 @@ GIT_EXTERN(const char *) git_remote_name(const git_remote *remote); * Get the remote's url * * If url.*.insteadOf has been configured for this URL, it will - * return the modified URL. + * return the modified URL. If `git_remote_set_instance_pushurl` + * has been called for this remote, then that URL will be returned. * * @param remote the remote * @return a pointer to the url @@ -220,10 +221,11 @@ GIT_EXTERN(const char *) git_remote_name(const git_remote *remote); GIT_EXTERN(const char *) git_remote_url(const git_remote *remote); /** - * Get the remote's url for pushing + * Get the remote's url for pushing. * * If url.*.pushInsteadOf has been configured for this URL, it - * will return the modified URL. + * will return the modified URL. If `git_remote_set_instance_pushurl` + * has been called for this remote, then that URL will be returned. * * @param remote the remote * @return a pointer to the url or NULL if no special url for pushing is set @@ -258,6 +260,26 @@ GIT_EXTERN(int) git_remote_set_url(git_repository *repo, const char *remote, con GIT_EXTERN(int) git_remote_set_pushurl(git_repository *repo, const char *remote, const char* url); /** + * Set the url for this particular url instance. The URL in the + * configuration will be ignored, and will not be changed. + * + * @param remote the remote's name + * @param url the url to set + * @return 0 or an error value + */ +GIT_EXTERN(int) git_remote_set_instance_url(git_remote *remote, const char *url); + +/** + * Set the push url for this particular url instance. The URL in the + * configuration will be ignored, and will not be changed. + * + * @param remote the remote's name + * @param url the url to set + * @return 0 or an error value + */ +GIT_EXTERN(int) git_remote_set_instance_pushurl(git_remote *remote, const char *url); + +/** * Add a fetch refspec to the remote's configuration * * Add the given refspec to the fetch list in the configuration. No @@ -477,6 +499,7 @@ typedef int GIT_CALLBACK(git_push_negotiation)(const git_push_update **updates, */ typedef int GIT_CALLBACK(git_push_update_reference_cb)(const char *refname, const char *status, void *data); +#ifndef GIT_DEPRECATE_HARD /** * Callback to resolve URLs before connecting to remote * @@ -488,8 +511,22 @@ typedef int GIT_CALLBACK(git_push_update_reference_cb)(const char *refname, cons * @param direction GIT_DIRECTION_FETCH or GIT_DIRECTION_PUSH * @param payload Payload provided by the caller * @return 0 on success, GIT_PASSTHROUGH or an error + * @deprecated Use `git_remote_set_instance_url` */ typedef int GIT_CALLBACK(git_url_resolve_cb)(git_buf *url_resolved, const char *url, int direction, void *payload); +#endif + +/** + * Callback invoked immediately before we attempt to connect to the + * given url. Callers may change the URL before the connection by + * calling `git_remote_set_instance_url` in the callback. + * + * @param remote The remote to be connected + * @param direction GIT_DIRECTION_FETCH or GIT_DIRECTION_PUSH + * @param payload Payload provided by the caller + * @return 0 on success, or an error + */ +typedef int GIT_CALLBACK(git_remote_ready_cb)(git_remote *remote, int direction, void *payload); /** * The callback settings structure @@ -576,16 +613,28 @@ struct git_remote_callbacks { git_transport_cb transport; /** + * Callback when the remote is ready to connect. + */ + git_remote_ready_cb remote_ready; + + /** * This will be passed to each of the callbacks in this struct * as the last parameter. */ void *payload; +#ifdef GIT_DEPRECATE_HARD + void *reserved; +#else /** * Resolve URL before connecting to remote. * The returned URL will be used to connect to the remote instead. + * + * This callback is deprecated; users should use + * git_remote_ready_cb and configure the instance URL instead. */ git_url_resolve_cb resolve_url; +#endif }; #define GIT_REMOTE_CALLBACKS_VERSION 1 |
