summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/clone.c30
-rw-r--r--src/fetch.c19
-rw-r--r--src/fetch.h2
-rw-r--r--src/push.c29
-rw-r--r--src/push.h4
-rw-r--r--src/remote.c123
-rw-r--r--src/remote.h1
-rw-r--r--src/submodule.c2
-rw-r--r--src/transports/local.c8
-rw-r--r--src/transports/smart.h2
-rw-r--r--src/transports/smart_protocol.c7
11 files changed, 124 insertions, 103 deletions
diff --git a/src/clone.c b/src/clone.c
index 7e5d3302e..53cdae673 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -24,7 +24,7 @@
#include "repository.h"
#include "odb.h"
-static int clone_local_into(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, int link);
+static int clone_local_into(git_repository *repo, git_remote *remote, const git_fetch_options *fetch_opts, const git_checkout_options *co_opts, const char *branch, int link);
static int create_branch(
git_reference **branch,
@@ -242,13 +242,9 @@ static int default_remote_create(
const char *url,
void *payload)
{
- int error;
- git_remote_callbacks *callbacks = payload;
-
- if ((error = git_remote_create(out, repo, name, url)) < 0)
- return error;
+ GIT_UNUSED(payload);
- return git_remote_set_callbacks(*out, callbacks);
+ return git_remote_create(out, repo, name, url);
}
/*
@@ -277,7 +273,7 @@ static int create_and_configure_origin(
if (!remote_create) {
remote_create = default_remote_create;
- payload = (void *)&options->remote_callbacks;
+ payload = NULL;
}
if ((error = remote_create(&origin, repo, "origin", url, payload)) < 0)
@@ -328,12 +324,11 @@ static int checkout_branch(git_repository *repo, git_remote *remote, const git_c
return error;
}
-static int clone_into(git_repository *repo, git_remote *_remote, const git_checkout_options *co_opts, const char *branch)
+static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch_options *opts, const git_checkout_options *co_opts, const char *branch)
{
int error;
git_buf reflog_message = GIT_BUF_INIT;
git_remote *remote;
- const git_remote_callbacks *callbacks;
assert(repo && _remote);
@@ -345,18 +340,13 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_check
if ((error = git_remote_dup(&remote, _remote)) < 0)
return error;
- callbacks = git_remote_get_callbacks(_remote);
- if (!giterr__check_version(callbacks, 1, "git_remote_callbacks") &&
- (error = git_remote_set_callbacks(remote, callbacks)) < 0)
- goto cleanup;
-
if ((error = git_remote_add_fetch(remote, "refs/tags/*:refs/tags/*")) < 0)
goto cleanup;
git_remote_set_update_fetchhead(remote, 0);
git_buf_printf(&reflog_message, "clone: from %s", git_remote_url(remote));
- if ((error = git_remote_fetch(remote, NULL, git_buf_cstr(&reflog_message))) != 0)
+ if ((error = git_remote_fetch(remote, NULL, opts, git_buf_cstr(&reflog_message))) != 0)
goto cleanup;
error = checkout_branch(repo, remote, co_opts, branch, git_buf_cstr(&reflog_message));
@@ -439,11 +429,11 @@ int git_clone(
if (clone_local == 1)
error = clone_local_into(
- repo, origin, &options.checkout_opts,
+ repo, origin, &options.fetch_opts, &options.checkout_opts,
options.checkout_branch, link);
else if (clone_local == 0)
error = clone_into(
- repo, origin, &options.checkout_opts,
+ repo, origin, &options.fetch_opts, &options.checkout_opts,
options.checkout_branch);
else
error = -1;
@@ -506,7 +496,7 @@ static bool can_link(const char *src, const char *dst, int link)
#endif
}
-static int clone_local_into(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, int link)
+static int clone_local_into(git_repository *repo, git_remote *remote, const git_fetch_options *fetch_opts, const git_checkout_options *co_opts, const char *branch, int link)
{
int error, flags;
git_repository *src;
@@ -551,7 +541,7 @@ static int clone_local_into(git_repository *repo, git_remote *remote, const git_
git_buf_printf(&reflog_message, "clone: from %s", git_remote_url(remote));
- if ((error = git_remote_fetch(remote, NULL, git_buf_cstr(&reflog_message))) != 0)
+ if ((error = git_remote_fetch(remote, NULL, fetch_opts, git_buf_cstr(&reflog_message))) != 0)
goto cleanup;
error = checkout_branch(repo, remote, co_opts, branch, git_buf_cstr(&reflog_message));
diff --git a/src/fetch.c b/src/fetch.c
index f61685619..e59ae8621 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -127,13 +127,26 @@ int git_fetch_negotiate(git_remote *remote)
remote->refs.length);
}
-int git_fetch_download_pack(git_remote *remote)
+int git_fetch_download_pack(git_remote *remote, const git_remote_callbacks *callbacks)
{
git_transport *t = remote->transport;
+ git_transfer_progress_cb progress = NULL;
+ void *payload = NULL;
if (!remote->need_pack)
return 0;
- return t->download_pack(t, remote->repo, &remote->stats,
- remote->callbacks.transfer_progress, remote->callbacks.payload);
+ if (callbacks) {
+ progress = callbacks->transfer_progress;
+ payload = callbacks->payload;
+ }
+
+ return t->download_pack(t, remote->repo, &remote->stats, progress, payload);
+}
+
+int git_fetch_init_options(git_fetch_options *opts, unsigned int version)
+{
+ GIT_INIT_STRUCTURE_FROM_TEMPLATE(
+ opts, version, git_fetch_options, GIT_FETCH_OPTIONS_INIT);
+ return 0;
}
diff --git a/src/fetch.h b/src/fetch.h
index f66e44663..26d8a6b9d 100644
--- a/src/fetch.h
+++ b/src/fetch.h
@@ -11,7 +11,7 @@
int git_fetch_negotiate(git_remote *remote);
-int git_fetch_download_pack(git_remote *remote);
+int git_fetch_download_pack(git_remote *remote, const git_remote_callbacks *callbacks);
int git_fetch__download_pack(
git_transport *t,
diff --git a/src/push.c b/src/push.c
index a4b61cd35..cd219e905 100644
--- a/src/push.c
+++ b/src/push.c
@@ -155,7 +155,7 @@ int git_push_add_refspec(git_push *push, const char *refspec)
return 0;
}
-int git_push_update_tips(git_push *push)
+int git_push_update_tips(git_push *push, const git_remote_callbacks *callbacks)
{
git_buf remote_ref_name = GIT_BUF_INIT;
size_t i, j;
@@ -212,9 +212,9 @@ int git_push_update_tips(git_push *push)
fire_callback = 0;
}
- if (fire_callback && push->remote->callbacks.update_tips) {
- error = push->remote->callbacks.update_tips(git_buf_cstr(&remote_ref_name),
- &push_spec->roid, &push_spec->loid, push->remote->callbacks.payload);
+ if (fire_callback && callbacks && callbacks->update_tips) {
+ error = callbacks->update_tips(git_buf_cstr(&remote_ref_name),
+ &push_spec->roid, &push_spec->loid, callbacks->payload);
if (error < 0)
goto on_error;
@@ -571,11 +571,10 @@ static int calculate_work(git_push *push)
return 0;
}
-static int do_push(git_push *push)
+static int do_push(git_push *push, const git_remote_callbacks *callbacks)
{
int error = 0;
git_transport *transport = push->remote->transport;
- git_remote_callbacks *cbs = &push->remote->callbacks;
if (!transport->push) {
giterr_set(GITERR_NET, "Remote transport doesn't support push");
@@ -594,20 +593,20 @@ static int do_push(git_push *push)
git_packbuilder_set_threads(push->pb, push->pb_parallelism);
- if (cbs->pack_progress)
- if ((error = git_packbuilder_set_callbacks(push->pb, cbs->pack_progress, cbs->payload)) < 0)
+ if (callbacks && callbacks->pack_progress)
+ if ((error = git_packbuilder_set_callbacks(push->pb, callbacks->pack_progress, callbacks->payload)) < 0)
goto on_error;
if ((error = calculate_work(push)) < 0)
goto on_error;
- if (cbs->push_negotiation &&
- (error = cbs->push_negotiation((const git_push_update **) push->updates.contents,
- push->updates.length, cbs->payload)) < 0)
+ if (callbacks && callbacks->push_negotiation &&
+ (error = callbacks->push_negotiation((const git_push_update **) push->updates.contents,
+ push->updates.length, callbacks->payload)) < 0)
goto on_error;
if ((error = queue_objects(push)) < 0 ||
- (error = transport->push(transport, push)) < 0)
+ (error = transport->push(transport, push, callbacks)) < 0)
goto on_error;
on_error:
@@ -633,16 +632,16 @@ static int filter_refs(git_remote *remote)
return 0;
}
-int git_push_finish(git_push *push)
+int git_push_finish(git_push *push, const git_remote_callbacks *callbacks)
{
int error;
if (!git_remote_connected(push->remote) &&
- (error = git_remote_connect(push->remote, GIT_DIRECTION_PUSH)) < 0)
+ (error = git_remote_connect(push->remote, GIT_DIRECTION_PUSH, callbacks)) < 0)
return error;
if ((error = filter_refs(push->remote)) < 0 ||
- (error = do_push(push)) < 0)
+ (error = do_push(push, callbacks)) < 0)
return error;
if (!push->unpack_ok) {
diff --git a/src/push.h b/src/push.h
index fcba45c8e..094f96ca9 100644
--- a/src/push.h
+++ b/src/push.h
@@ -87,7 +87,7 @@ int git_push_add_refspec(git_push *push, const char *refspec);
*
* @return 0 or an error code
*/
-int git_push_update_tips(git_push *push);
+int git_push_update_tips(git_push *push, const git_remote_callbacks *callbacks);
/**
* Perform the push
@@ -103,7 +103,7 @@ int git_push_update_tips(git_push *push);
*
* @return 0 or an error code
*/
-int git_push_finish(git_push *push);
+int git_push_finish(git_push *push, const git_remote_callbacks *callbacks);
/**
* Invoke callback `cb' on each status entry
diff --git a/src/remote.c b/src/remote.c
index 91ebdd53c..85da2dc1b 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -691,15 +691,32 @@ const char* git_remote__urlfordirection(git_remote *remote, int direction)
return NULL;
}
-int git_remote_connect(git_remote *remote, git_direction direction)
+int set_transport_callbacks(git_transport *t, const git_remote_callbacks *cbs)
+{
+ if (!t->set_callbacks || !cbs)
+ return 0;
+
+ return t->set_callbacks(t, cbs->sideband_progress, NULL,
+ cbs->certificate_check, cbs->payload);
+}
+
+int git_remote_connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks)
{
git_transport *t;
const char *url;
int flags = GIT_TRANSPORTFLAGS_NONE;
int error;
+ void *payload = NULL;
+ git_cred_acquire_cb credentials;
assert(remote);
+ if (callbacks) {
+ GITERR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
+ credentials = callbacks->credentials;
+ payload = callbacks->payload;
+ }
+
t = remote->transport;
url = git_remote__urlfordirection(remote, direction);
@@ -720,11 +737,8 @@ int git_remote_connect(git_remote *remote, git_direction direction)
if (!t && (error = git_transport_new(&t, remote, url)) < 0)
return error;
- if (t->set_callbacks &&
- (error = t->set_callbacks(t, remote->callbacks.sideband_progress, NULL, remote->callbacks.certificate_check, remote->callbacks.payload)) < 0)
- goto on_error;
-
- if ((error = t->connect(t, url, remote->callbacks.credentials, remote->callbacks.payload, direction, flags)) != 0)
+ if ((error = set_transport_callbacks(t, callbacks)) < 0 ||
+ (error = t->connect(t, url, credentials, payload, direction, flags)) != 0)
goto on_error;
remote->transport = t;
@@ -866,14 +880,24 @@ static int ls_to_vector(git_vector *out, git_remote *remote)
return 0;
}
-int git_remote_download(git_remote *remote, const git_strarray *refspecs)
+int git_remote_download(git_remote *remote, const git_strarray *refspecs, const git_fetch_options *opts)
{
int error = -1;
size_t i;
git_vector refs, specs, *to_active;
+ const git_remote_callbacks *cbs = NULL;
assert(remote);
+ if (opts) {
+ GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
+ cbs = &opts->callbacks;
+ }
+
+ if (!git_remote_connected(remote) &&
+ (error = git_remote_connect(remote, GIT_DIRECTION_FETCH, cbs)) < 0)
+ goto on_error;
+
if (ls_to_vector(&refs, remote) < 0)
return -1;
@@ -915,7 +939,7 @@ int git_remote_download(git_remote *remote, const git_strarray *refspecs)
if ((error = git_fetch_negotiate(remote)) < 0)
return error;
- return git_fetch_download_pack(remote);
+ return git_fetch_download_pack(remote, cbs);
on_error:
git_vector_free(&refs);
@@ -927,16 +951,23 @@ on_error:
int git_remote_fetch(
git_remote *remote,
const git_strarray *refspecs,
+ const git_fetch_options *opts,
const char *reflog_message)
{
int error;
git_buf reflog_msg_buf = GIT_BUF_INIT;
+ const git_remote_callbacks *cbs = NULL;
+
+ if (opts) {
+ GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
+ cbs = &opts->callbacks;
+ }
/* Connect and download everything */
- if ((error = git_remote_connect(remote, GIT_DIRECTION_FETCH)) != 0)
+ if ((error = git_remote_connect(remote, GIT_DIRECTION_FETCH, cbs)) != 0)
return error;
- error = git_remote_download(remote, refspecs);
+ error = git_remote_download(remote, refspecs, opts);
/* We don't need to be connected anymore */
git_remote_disconnect(remote);
@@ -954,13 +985,13 @@ int git_remote_fetch(
}
/* Create "remote/foo" branches for all remote branches */
- error = git_remote_update_tips(remote, git_buf_cstr(&reflog_msg_buf));
+ error = git_remote_update_tips(remote, cbs, git_buf_cstr(&reflog_msg_buf));
git_buf_free(&reflog_msg_buf);
if (error < 0)
return error;
if (remote->prune_refs)
- error = git_remote_prune(remote);
+ error = git_remote_prune(remote, cbs);
return error;
}
@@ -1156,7 +1187,7 @@ static int find_head(const void *_a, const void *_b)
return strcmp(a->name, b->name);
}
-int git_remote_prune(git_remote *remote)
+int git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks)
{
size_t i, j;
git_vector remote_refs = GIT_VECTOR_INIT;
@@ -1166,6 +1197,9 @@ int git_remote_prune(git_remote *remote)
int error;
git_oid zero_id = {{ 0 }};
+ if (callbacks)
+ GITERR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
+
if ((error = ls_to_vector(&remote_refs, remote)) < 0)
goto cleanup;
@@ -1242,8 +1276,8 @@ int git_remote_prune(git_remote *remote)
if (error < 0)
goto cleanup;
- if (remote->callbacks.update_tips)
- error = remote->callbacks.update_tips(refname, &id, &zero_id, remote->callbacks.payload);
+ if (callbacks && callbacks->update_tips)
+ error = callbacks->update_tips(refname, &id, &zero_id, callbacks->payload);
if (error < 0)
goto cleanup;
@@ -1257,6 +1291,7 @@ cleanup:
static int update_tips_for_spec(
git_remote *remote,
+ const git_remote_callbacks *callbacks,
git_refspec *spec,
git_vector *refs,
const char *log_message)
@@ -1339,8 +1374,8 @@ static int update_tips_for_spec(
git_reference_free(ref);
- if (remote->callbacks.update_tips != NULL) {
- if (remote->callbacks.update_tips(refname.ptr, &old, &head->oid, remote->callbacks.payload) < 0)
+ if (callbacks && callbacks->update_tips != NULL) {
+ if (callbacks->update_tips(refname.ptr, &old, &head->oid, callbacks->payload) < 0)
goto on_error;
}
}
@@ -1455,6 +1490,7 @@ static int opportunistic_updates(const git_remote *remote, git_vector *refs, con
int git_remote_update_tips(
git_remote *remote,
+ const git_remote_callbacks *callbacks,
const char *reflog_message)
{
git_refspec *spec, tagspec;
@@ -1464,7 +1500,7 @@ int git_remote_update_tips(
/* push has its own logic hidden away in the push object */
if (remote->push) {
- return git_push_update_tips(remote->push);
+ return git_push_update_tips(remote->push, callbacks);
}
if (git_refspec__parse(&tagspec, GIT_REFSPEC_TAGS, true) < 0)
@@ -1475,7 +1511,7 @@ int git_remote_update_tips(
goto out;
if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
- if ((error = update_tips_for_spec(remote, &tagspec, &refs, reflog_message)) < 0)
+ if ((error = update_tips_for_spec(remote, callbacks, &tagspec, &refs, reflog_message)) < 0)
goto out;
}
@@ -1483,7 +1519,7 @@ int git_remote_update_tips(
if (spec->push)
continue;
- if ((error = update_tips_for_spec(remote, spec, &refs, reflog_message)) < 0)
+ if ((error = update_tips_for_spec(remote, callbacks, spec, &refs, reflog_message)) < 0)
goto out;
}
@@ -1600,31 +1636,6 @@ int git_remote_list(git_strarray *remotes_list, git_repository *repo)
return 0;
}
-int git_remote_set_callbacks(git_remote *remote, const git_remote_callbacks *callbacks)
-{
- assert(remote && callbacks);
-
- GITERR_CHECK_VERSION(callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
-
- memcpy(&remote->callbacks, callbacks, sizeof(git_remote_callbacks));
-
- if (remote->transport && remote->transport->set_callbacks)
- return remote->transport->set_callbacks(remote->transport,
- remote->callbacks.sideband_progress,
- NULL,
- remote->callbacks.certificate_check,
- remote->callbacks.payload);
-
- return 0;
-}
-
-const git_remote_callbacks *git_remote_get_callbacks(git_remote *remote)
-{
- assert(remote);
-
- return &remote->callbacks;
-}
-
int git_remote_set_transport(
git_remote *remote,
git_transport_cb transport_cb,
@@ -2321,12 +2332,15 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
int error;
git_push *push;
git_refspec *spec;
- git_remote_callbacks *cbs;
+ const git_remote_callbacks *cbs = NULL;
assert(remote);
+ if (opts)
+ cbs = &opts->callbacks;
+
if (!git_remote_connected(remote) &&
- (error = git_remote_connect(remote, GIT_DIRECTION_PUSH)) < 0)
+ (error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs)) < 0)
goto cleanup;
free_refspecs(&remote->active_refspecs);
@@ -2360,11 +2374,10 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
}
}
- if ((error = git_push_finish(push)) < 0)
+ if ((error = git_push_finish(push, cbs)) < 0)
goto cleanup;
- cbs = &remote->callbacks;
- if (cbs->push_update_reference &&
+ if (cbs && cbs->push_update_reference &&
(error = git_push_status_foreach(push, cbs->push_update_reference, cbs->payload)) < 0)
goto cleanup;
@@ -2375,16 +2388,22 @@ cleanup:
int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_push_options *opts)
{
int error;
+ const git_remote_callbacks *cbs = NULL;
+
+ if (opts) {
+ GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
+ cbs = &opts->callbacks;
+ }
assert(remote && refspecs);
- if ((error = git_remote_connect(remote, GIT_DIRECTION_PUSH)) < 0)
+ if ((error = git_remote_connect(remote, GIT_DIRECTION_PUSH, cbs)) < 0)
return error;
if ((error = git_remote_upload(remote, refspecs, opts)) < 0)
return error;
- error = git_remote_update_tips(remote, NULL);
+ error = git_remote_update_tips(remote, cbs, NULL);
git_remote_disconnect(remote);
return error;
diff --git a/src/remote.h b/src/remote.h
index a28b565ce..4fb2351d9 100644
--- a/src/remote.h
+++ b/src/remote.h
@@ -29,7 +29,6 @@ struct git_remote {
git_transport *transport;
git_repository *repo;
git_push *push;
- git_remote_callbacks callbacks;
git_transfer_progress stats;
unsigned int need_pack;
git_remote_autotag_option_t download_tags;
diff --git a/src/submodule.c b/src/submodule.c
index d24a7773a..1139df973 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -950,7 +950,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
GITERR_CHECK_VERSION(&update_options, GIT_SUBMODULE_UPDATE_OPTIONS_VERSION, "git_submodule_update_options");
/* Copy over the remote callbacks */
- clone_options.remote_callbacks = update_options.remote_callbacks;
+ memcpy(&clone_options.fetch_opts, &update_options.fetch_opts, sizeof(git_fetch_options));
/* Get the status of the submodule to determine if it is already initialized */
if ((error = git_submodule_status(&submodule_status, sm)) < 0)
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,