Merge pull request #1906 from libgit2/cmn/net-cb-errors transport: let the progress output return an error
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
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 9858634..f4cd1cb 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -410,7 +410,7 @@ struct git_remote_callbacks {
* progress side-band will be passed to this function (this is
* the 'counting objects' output.
*/
- void (*progress)(const char *str, int len, void *data);
+ int (*progress)(const char *str, int len, void *data);
/**
* Completion is called when different parts of the download
diff --git a/include/git2/transport.h b/include/git2/transport.h
index 065b318..b9fda80 100644
--- a/include/git2/transport.h
+++ b/include/git2/transport.h
@@ -170,7 +170,7 @@ typedef enum {
GIT_TRANSPORTFLAGS_NO_CHECK_CERT = 1
} git_transport_flags_t;
-typedef void (*git_transport_message_cb)(const char *str, int len, void *data);
+typedef int (*git_transport_message_cb)(const char *str, int len, void *data);
typedef struct git_transport git_transport;
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index 2467790..3b4d578 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -509,7 +509,10 @@ int git_smart__download_pack(
if (pkt->type == GIT_PKT_PROGRESS) {
if (t->progress_cb) {
git_pkt_progress *p = (git_pkt_progress *) pkt;
- t->progress_cb(p->data, p->len, t->message_cb_payload);
+ if (t->progress_cb(p->data, p->len, t->message_cb_payload)) {
+ giterr_set(GITERR_NET, "The fetch was cancelled by the user");
+ return GIT_EUSER;
+ }
}
git__free(pkt);
} else if (pkt->type == GIT_PKT_DATA) {