mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 10:03:43 +00:00
Accept custom headers for fetch too
This commit is contained in:
parent
c82c2ba60f
commit
c49126c87f
@ -547,6 +547,11 @@ typedef struct {
|
|||||||
* The default is to auto-follow tags.
|
* The default is to auto-follow tags.
|
||||||
*/
|
*/
|
||||||
git_remote_autotag_option_t download_tags;
|
git_remote_autotag_option_t download_tags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extra headers for this fetch operation
|
||||||
|
*/
|
||||||
|
git_strarray custom_headers;
|
||||||
} git_fetch_options;
|
} git_fetch_options;
|
||||||
|
|
||||||
#define GIT_FETCH_OPTIONS_VERSION 1
|
#define GIT_FETCH_OPTIONS_VERSION 1
|
||||||
|
@ -895,16 +895,18 @@ int git_remote_download(git_remote *remote, const git_strarray *refspecs, const
|
|||||||
size_t i;
|
size_t i;
|
||||||
git_vector *to_active, specs = GIT_VECTOR_INIT, refs = GIT_VECTOR_INIT;
|
git_vector *to_active, specs = GIT_VECTOR_INIT, refs = GIT_VECTOR_INIT;
|
||||||
const git_remote_callbacks *cbs = NULL;
|
const git_remote_callbacks *cbs = NULL;
|
||||||
|
const git_strarray *custom_headers = NULL;
|
||||||
|
|
||||||
assert(remote);
|
assert(remote);
|
||||||
|
|
||||||
if (opts) {
|
if (opts) {
|
||||||
GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
||||||
cbs = &opts->callbacks;
|
cbs = &opts->callbacks;
|
||||||
|
custom_headers = &opts->custom_headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!git_remote_connected(remote) &&
|
if (!git_remote_connected(remote) &&
|
||||||
(error = git_remote_connect(remote, GIT_DIRECTION_FETCH, cbs, NULL)) < 0)
|
(error = git_remote_connect(remote, GIT_DIRECTION_FETCH, cbs, custom_headers)) < 0)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
|
||||||
if (ls_to_vector(&refs, remote) < 0)
|
if (ls_to_vector(&refs, remote) < 0)
|
||||||
@ -968,16 +970,18 @@ int git_remote_fetch(
|
|||||||
bool prune = false;
|
bool prune = false;
|
||||||
git_buf reflog_msg_buf = GIT_BUF_INIT;
|
git_buf reflog_msg_buf = GIT_BUF_INIT;
|
||||||
const git_remote_callbacks *cbs = NULL;
|
const git_remote_callbacks *cbs = NULL;
|
||||||
|
const git_strarray *custom_headers = NULL;
|
||||||
|
|
||||||
if (opts) {
|
if (opts) {
|
||||||
GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
|
||||||
cbs = &opts->callbacks;
|
cbs = &opts->callbacks;
|
||||||
|
custom_headers = &opts->custom_headers;
|
||||||
update_fetchhead = opts->update_fetchhead;
|
update_fetchhead = opts->update_fetchhead;
|
||||||
tagopt = opts->download_tags;
|
tagopt = opts->download_tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Connect and download everything */
|
/* Connect and download everything */
|
||||||
if ((error = git_remote_connect(remote, GIT_DIRECTION_FETCH, cbs, NULL)) != 0)
|
if ((error = git_remote_connect(remote, GIT_DIRECTION_FETCH, cbs, custom_headers)) != 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
error = git_remote_download(remote, refspecs, opts);
|
error = git_remote_download(remote, refspecs, opts);
|
||||||
|
Loading…
Reference in New Issue
Block a user