Commit 4f62163ead2bde1af3cd7d0c0b8990e1831d3ffd

Jacques Germishuys 2014-04-20T22:06:05

Check the return codes of remote callbacks. The user may have requested that the operation be cancelled.

diff --git a/include/git2/remote.h b/include/git2/remote.h
index 88040d4..d57321f 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -455,8 +455,7 @@ struct git_remote_callbacks {
 	/**
 	 * Textual progress from the remote. Text send over the
 	 * progress side-band will be passed to this function (this is
-	 * the 'counting objects' output. This callback should return a value less
-	 * than zero to cancel the operation.
+	 * the 'counting objects' output.
 	 */
 	int (*progress)(const char *str, int len, void *data);
 
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index e5b56ea..6f93517 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -882,10 +882,7 @@ static int stream_thunk(void *buf, size_t size, void *data)
 
 		if ((current_time - payload->last_progress_report_time) >= MIN_PROGRESS_UPDATE_INTERVAL) {
 			payload->last_progress_report_time = current_time;
-			if (payload->cb(payload->pb->nr_written, payload->pb->nr_objects, payload->last_bytes, payload->cb_payload)) {
-				giterr_clear();
-				error = GIT_EUSER;
-			}
+			error = payload->cb(payload->pb->nr_written, payload->pb->nr_objects, payload->last_bytes, payload->cb_payload);
 		}
 	}
 
@@ -957,7 +954,14 @@ int git_smart__push(git_transport *transport, git_push *push)
 
 	/* If progress is being reported write the final report */
 	if (push->transfer_progress_cb) {
-		push->transfer_progress_cb(push->pb->nr_written, push->pb->nr_objects, packbuilder_payload.last_bytes, push->transfer_progress_cb_payload);
+		error = push->transfer_progress_cb(
+					push->pb->nr_written,
+					push->pb->nr_objects,
+					packbuilder_payload.last_bytes,
+					push->transfer_progress_cb_payload);
+
+		if (error < 0)
+			goto done;
 	}
 
 	if (push->status.length) {