diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2015-04-22 15:45:21 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-05-13 09:46:36 +0200 |
| commit | 058b753ceb8f6b25b77e57106b3a87997bc6362a (patch) | |
| tree | 2ad699eda443d924a51d18aaa61c22e10f7eba31 /src/remote.c | |
| parent | 6fb373a0e8eeff3c94853ff0ac55ca6b561c44a1 (diff) | |
| download | libgit2-058b753ceb8f6b25b77e57106b3a87997bc6362a.tar.gz | |
remote: move the transport ctor to the callbacks
Instead of having it set in a different place from every other callback,
put it the main structure. This removes some state from the remote and
makes it behave more like clone, where the constructors are passed via
the options.
Diffstat (limited to 'src/remote.c')
| -rw-r--r-- | src/remote.c | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/src/remote.c b/src/remote.c index a29b8aad9..95c316f54 100644 --- a/src/remote.c +++ b/src/remote.c @@ -309,8 +309,6 @@ int git_remote_dup(git_remote **dest, git_remote *source) GITERR_CHECK_ALLOC(remote->pushurl); } - remote->transport_cb = source->transport_cb; - remote->transport_cb_payload = source->transport_cb_payload; remote->repo = source->repo; remote->download_tags = source->download_tags; remote->update_fetchhead = source->update_fetchhead; @@ -725,13 +723,15 @@ int git_remote_connect(git_remote *remote, git_direction direction, const git_re int flags = GIT_TRANSPORTFLAGS_NONE; int error; void *payload = NULL; - git_cred_acquire_cb credentials; + git_cred_acquire_cb credentials = NULL; + git_transport_cb transport = NULL; assert(remote); if (callbacks) { GITERR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks"); credentials = callbacks->credentials; + transport = callbacks->transport; payload = callbacks->payload; } @@ -746,8 +746,8 @@ int git_remote_connect(git_remote *remote, git_direction direction, const git_re /* If we don't have a transport object yet, and the caller specified a * custom transport factory, use that */ - if (!t && remote->transport_cb && - (error = remote->transport_cb(&t, remote, remote->transport_cb_payload)) < 0) + if (!t && transport && + (error = transport(&t, remote, payload)) < 0) return error; /* If we still don't have a transport, then use the global @@ -1664,23 +1664,6 @@ int git_remote_list(git_strarray *remotes_list, git_repository *repo) return 0; } -int git_remote_set_transport( - git_remote *remote, - git_transport_cb transport_cb, - void *payload) -{ - assert(remote); - - if (remote->transport) { - giterr_set(GITERR_NET, "A transport is already bound to this remote"); - return -1; - } - - remote->transport_cb = transport_cb; - remote->transport_cb_payload = payload; - return 0; -} - const git_transfer_progress* git_remote_stats(git_remote *remote) { assert(remote); |
