summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Burke <spraints@gmail.com>2015-09-10 08:34:35 -0400
committerMatt Burke <spraints@gmail.com>2015-09-10 08:34:35 -0400
commitc49126c87f1124d0928d68d9191535e5ef4ecd25 (patch)
tree4099f0fe7ae22cadaaac4149b422e04da5564357
parentc82c2ba60f63095a3b418424d858277f5800b914 (diff)
downloadlibgit2-c49126c87f1124d0928d68d9191535e5ef4ecd25.tar.gz
Accept custom headers for fetch too
-rw-r--r--include/git2/remote.h5
-rw-r--r--src/remote.c8
2 files changed, 11 insertions, 2 deletions
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 9237ca255..c42d96710 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -547,6 +547,11 @@ typedef struct {
* The default is to auto-follow tags.
*/
git_remote_autotag_option_t download_tags;
+
+ /**
+ * Extra headers for this fetch operation
+ */
+ git_strarray custom_headers;
} git_fetch_options;
#define GIT_FETCH_OPTIONS_VERSION 1
diff --git a/src/remote.c b/src/remote.c
index 9e907d281..a374a84b3 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -895,16 +895,18 @@ int git_remote_download(git_remote *remote, const git_strarray *refspecs, const
size_t i;
git_vector *to_active, specs = GIT_VECTOR_INIT, refs = GIT_VECTOR_INIT;
const git_remote_callbacks *cbs = NULL;
+ const git_strarray *custom_headers = NULL;
assert(remote);
if (opts) {
GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
cbs = &opts->callbacks;
+ custom_headers = &opts->custom_headers;
}
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;
if (ls_to_vector(&refs, remote) < 0)
@@ -968,16 +970,18 @@ int git_remote_fetch(
bool prune = false;
git_buf reflog_msg_buf = GIT_BUF_INIT;
const git_remote_callbacks *cbs = NULL;
+ const git_strarray *custom_headers = NULL;
if (opts) {
GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
cbs = &opts->callbacks;
+ custom_headers = &opts->custom_headers;
update_fetchhead = opts->update_fetchhead;
tagopt = opts->download_tags;
}
/* 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;
error = git_remote_download(remote, refspecs, opts);