Hash :
6fc6eeb6
Author :
Date :
2021-12-24T15:14:38
remote: introduce `git_remote_connect_options` The existing mechanism for providing options to remote fetch/push calls, and subsequently to transports, is unsatisfactory. It requires an options structure to avoid breaking the API and callback signatures. 1. Introduce `git_remote_connect_options` to satisfy those needs. 2. Add a new remote connection API, `git_remote_connect_ext` that will take this new options structure. Existing `git_remote_connect` calls will proxy to that. `git_remote_fetch` and `git_remote_push` will proxy their fetch/push options to that as well. 3. Define the interaction between `git_remote_connect` and fetch/push. Connect _may_ be called before fetch/push, but _need not_ be. The semantics of which options would be used for these operations was not specified if you specify options for both connect _and_ fetch. Now these are defined that the fetch or push options will be used _if_ they were specified. Otherwise, the connect options will be used if they were specified. Otherwise, the library's defaults will be used. 4. Update the transports to understand `git_remote_connect_options`. This is a breaking change to the systems API.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#include "proxy.h"
#include "git2/proxy.h"
int git_proxy_options_init(git_proxy_options *opts, unsigned int version)
{
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
opts, version, git_proxy_options, GIT_PROXY_OPTIONS_INIT);
return 0;
}
#ifndef GIT_DEPRECATE_HARD
int git_proxy_init_options(git_proxy_options *opts, unsigned int version)
{
return git_proxy_options_init(opts, version);
}
#endif
int git_proxy_options_dup(git_proxy_options *tgt, const git_proxy_options *src)
{
if (!src) {
git_proxy_options_init(tgt, GIT_PROXY_OPTIONS_VERSION);
return 0;
}
memcpy(tgt, src, sizeof(git_proxy_options));
if (src->url) {
tgt->url = git__strdup(src->url);
GIT_ERROR_CHECK_ALLOC(tgt->url);
}
return 0;
}
void git_proxy_options_dispose(git_proxy_options *opts)
{
if (!opts)
return;
git__free((char *) opts->url);
opts->url = NULL;
}