summaryrefslogtreecommitdiff
path: root/src/transports
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-04-21 22:10:36 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-05-13 09:46:35 +0200
commit8f0104ecc54db00a075310ab744a19eb60e3d740 (patch)
tree775b3237a853c556a4d44840fc6c562e7b114415 /src/transports
parent05259114427234831cf4915cbe40a5bb8ea021b0 (diff)
downloadlibgit2-8f0104ecc54db00a075310ab744a19eb60e3d740.tar.gz
Remove the callbacks struct from the remote
Having the setting be different from calling its actions was not a great idea and made for the sake of the wrong convenience. Instead of that, accept either fetch options, push options or the callbacks when dealing with the remote. The fetch options are currently only the callbacks, but more options will be moved from setters and getters on the remote to the options. This does mean passing the same struct along the different functions but the typical use-case will only call git_remote_fetch() or git_remote_push() and so won't notice much difference.
Diffstat (limited to 'src/transports')
-rw-r--r--src/transports/local.c8
-rw-r--r--src/transports/smart.h2
-rw-r--r--src/transports/smart_protocol.c7
3 files changed, 9 insertions, 8 deletions
diff --git a/src/transports/local.c b/src/transports/local.c
index def8ac037..305c71bf0 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -16,7 +16,6 @@
#include "git2/pack.h"
#include "git2/commit.h"
#include "git2/revparse.h"
-#include "git2/push.h"
#include "pack-objects.h"
#include "refs.h"
#include "posix.h"
@@ -366,7 +365,8 @@ static int local_push_update_remote_ref(
static int local_push(
git_transport *transport,
- git_push *push)
+ git_push *push,
+ const git_remote_callbacks *cbs)
{
transport_local *t = (transport_local *)transport;
git_odb *remote_odb = NULL;
@@ -380,6 +380,8 @@ static int local_push(
unsigned int i;
size_t j;
+ GIT_UNUSED(cbs);
+
/* 'push->remote->url' may be a url or path; convert to a path */
if ((error = git_path_from_url_or_path(&buf, push->remote->url)) < 0) {
git_buf_free(&buf);
@@ -471,7 +473,7 @@ static int local_push(
if (!url || t->parent.close(&t->parent) < 0 ||
t->parent.connect(&t->parent, url,
- push->remote->callbacks.credentials, NULL, GIT_DIRECTION_PUSH, flags))
+ NULL, NULL, GIT_DIRECTION_PUSH, flags))
goto on_error;
}
diff --git a/src/transports/smart.h b/src/transports/smart.h
index 44e241adc..4c728c7cc 100644
--- a/src/transports/smart.h
+++ b/src/transports/smart.h
@@ -158,7 +158,7 @@ typedef struct {
/* smart_protocol.c */
int git_smart__store_refs(transport_smart *t, int flushes);
int git_smart__detect_caps(git_pkt_ref *pkt, transport_smart_caps *caps, git_vector *symrefs);
-int git_smart__push(git_transport *transport, git_push *push);
+int git_smart__push(git_transport *transport, git_push *push, const git_remote_callbacks *cbs);
int git_smart__negotiate_fetch(
git_transport *transport,
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index 9e7b0a72b..7f6b74ca7 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -946,11 +946,10 @@ static int stream_thunk(void *buf, size_t size, void *data)
return error;
}
-int git_smart__push(git_transport *transport, git_push *push)
+int git_smart__push(git_transport *transport, git_push *push, const git_remote_callbacks *cbs)
{
transport_smart *t = (transport_smart *)transport;
struct push_packbuilder_payload packbuilder_payload = {0};
- git_remote_callbacks *cbs = &push->remote->callbacks;
git_buf pktline = GIT_BUF_INIT;
int error = 0, need_pack = 0;
push_spec *spec;
@@ -958,7 +957,7 @@ int git_smart__push(git_transport *transport, git_push *push)
packbuilder_payload.pb = push->pb;
- if (cbs->transfer_progress) {
+ if (cbs && cbs->transfer_progress) {
packbuilder_payload.cb = cbs->push_transfer_progress;
packbuilder_payload.cb_payload = cbs->payload;
}
@@ -1011,7 +1010,7 @@ int git_smart__push(git_transport *transport, git_push *push)
goto done;
/* If progress is being reported write the final report */
- if (cbs->push_transfer_progress) {
+ if (cbs && cbs->push_transfer_progress) {
error = cbs->push_transfer_progress(
push->pb->nr_written,
push->pb->nr_objects,