diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2022-01-04 06:16:30 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2022-01-13 21:34:20 +0000 |
commit | 515daeaf4d5918ae93b02a5478adee563b4dac5e (patch) | |
tree | 9d7a652e2ae10eb01227cd29c85e3595cb210155 /include | |
parent | 342e55ac9104346d925154b5d472cf5f58668f0d (diff) | |
download | libgit2-515daeaf4d5918ae93b02a5478adee563b4dac5e.tar.gz |
remote: introduce `follow_redirects` connect option
Give callers the ability to select how to handle redirects - either
supporting redirects during the initial connection (so that, for
example, `git.example.com/repo` can redirect to `github.com/example/repo`)
or all/no redirects. This is for compatibility with git.
Diffstat (limited to 'include')
-rw-r--r-- | include/git2/remote.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/include/git2/remote.h b/include/git2/remote.h index f1aa35f47..162b076ea 100644 --- a/include/git2/remote.h +++ b/include/git2/remote.h @@ -42,6 +42,30 @@ GIT_EXTERN(int) git_remote_create( const char *url); /** + * Remote redirection settings; whether redirects to another host + * are permitted. By default, git will follow a redirect on the + * initial request (`/info/refs`), but not subsequent requests. + */ +typedef enum { + /** + * Do not follow any off-site redirects at any stage of + * the fetch or push. + */ + GIT_REMOTE_REDIRECT_NONE = (1 << 0), + + /** + * Allow off-site redirects only upon the initial request. + * This is the default. + */ + GIT_REMOTE_REDIRECT_INITIAL = (1 << 1), + + /** + * Allow redirects at any stage in the fetch or push. + */ + GIT_REMOTE_REDIRECT_ALL = (1 << 2) +} git_remote_redirect_t; + +/** * Remote creation options flags */ typedef enum { @@ -718,6 +742,13 @@ typedef struct { git_proxy_options proxy_opts; /** + * Whether to allow off-site redirects. If this is not + * specified, the `http.followRedirects` configuration setting + * will be consulted. + */ + git_remote_redirect_t follow_redirects; + + /** * Extra headers for this fetch operation */ git_strarray custom_headers; @@ -769,6 +800,13 @@ typedef struct { git_proxy_options proxy_opts; /** + * Whether to allow off-site redirects. If this is not + * specified, the `http.followRedirects` configuration setting + * will be consulted. + */ + git_remote_redirect_t follow_redirects; + + /** * Extra headers for this push operation */ git_strarray custom_headers; @@ -807,6 +845,13 @@ typedef struct { /** HTTP Proxy settings */ git_proxy_options proxy_opts; + /** + * Whether to allow off-site redirects. If this is not + * specified, the `http.followRedirects` configuration setting + * will be consulted. + */ + git_remote_redirect_t follow_redirects; + /** Extra HTTP headers to use in this connection */ git_strarray custom_headers; } git_remote_connect_options; |