Remove 'bytes' param from git_remote_download
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
diff --git a/examples/network/fetch.c b/examples/network/fetch.c
index 8bfe10c..496498e 100644
--- a/examples/network/fetch.c
+++ b/examples/network/fetch.c
@@ -8,7 +8,6 @@
struct dl_data {
git_remote *remote;
- git_off_t *bytes;
int ret;
int finished;
};
@@ -34,7 +33,7 @@ static void *download(void *ptr)
// Download the packfile and index it. This function updates the
// amount of received data and the indexer stats which lets you
// inform the user about progress.
- if (git_remote_download(data->remote, data->bytes, NULL, NULL) < 0) {
+ if (git_remote_download(data->remote, NULL, NULL) < 0) {
data->ret = -1;
goto exit;
}
@@ -68,7 +67,6 @@ static int update_cb(const char *refname, const git_oid *a, const git_oid *b, vo
int fetch(git_repository *repo, int argc, char **argv)
{
git_remote *remote = NULL;
- git_off_t bytes = 0;
const git_transfer_progress *stats;
pthread_t worker;
struct dl_data data;
@@ -90,7 +88,6 @@ int fetch(git_repository *repo, int argc, char **argv)
// Set up the information for the background worker thread
data.remote = remote;
- data.bytes = &bytes;
data.ret = 0;
data.finished = 0;
@@ -108,7 +105,7 @@ int fetch(git_repository *repo, int argc, char **argv)
if (stats->total_objects > 0)
printf("Received %d/%d objects (%d) in %d bytes\r",
stats->received_objects, stats->total_objects,
- stats->indexed_objects, bytes);
+ stats->indexed_objects, stats->received_bytes);
} while (!data.finished);
if (data.ret < 0)
@@ -116,7 +113,7 @@ int fetch(git_repository *repo, int argc, char **argv)
pthread_join(worker, NULL);
printf("\rReceived %d/%d objects in %zu bytes\n",
- stats->indexed_objects, stats->total_objects, bytes);
+ stats->indexed_objects, stats->total_objects, stats->received_bytes);
// Disconnect the underlying connection to prevent from idling.
git_remote_disconnect(remote);
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 897dfde..1ec1a08 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -183,8 +183,6 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void
* filename will be NULL and the function will return success.
*
* @param remote the remote to download from
- * @param bytes buffer that receives the number of bytes transferred (updated
- * while transfer is in progress)
* @param progress_cb function to call with progress information. Be aware that
* this is called inline with network and indexing operations, so performance
* may be affected.
@@ -193,7 +191,6 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void
*/
GIT_EXTERN(int) git_remote_download(
git_remote *remote,
- git_off_t *bytes,
git_transfer_progress_callback progress_cb,
void *progress_payload);
diff --git a/src/clone.c b/src/clone.c
index fc2bfa1..ab8b9bc 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -256,13 +256,12 @@ static int setup_remotes_and_fetch(
{
int retcode = GIT_ERROR;
git_remote *origin = NULL;
- git_off_t bytes = 0;
/* Create the "origin" remote */
if (!git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, origin_url)) {
/* Connect and download everything */
if (!git_remote_connect(origin, GIT_DIR_FETCH)) {
- if (!git_remote_download(origin, &bytes, progress_cb, progress_payload)) {
+ if (!git_remote_download(origin, progress_cb, progress_payload)) {
/* Create "origin/foo" branches for all remote branches */
if (!git_remote_update_tips(origin)) {
/* Point HEAD to the same ref as the remote's head */
diff --git a/src/fetch.c b/src/fetch.c
index ee85f08..0aabe74 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -306,7 +306,6 @@ on_error:
int git_fetch_download_pack(
git_remote *remote,
- git_off_t *bytes,
git_transfer_progress_callback progress_cb,
void *progress_payload)
{
@@ -316,14 +315,14 @@ int git_fetch_download_pack(
return 0;
if (t->own_logic)
- return t->download_pack(t, remote->repo, bytes, &remote->stats);
+ return t->download_pack(t, remote->repo, &remote->stats);
- return git_fetch__download_pack(t, remote->repo, bytes, &remote->stats,
+ return git_fetch__download_pack(t, remote->repo, &remote->stats,
progress_cb, progress_payload);
}
-static int no_sideband(git_transport *t, git_indexer_stream *idx, gitno_buffer *buf, git_off_t *bytes, git_transfer_progress *stats)
+static int no_sideband(git_transport *t, git_indexer_stream *idx, gitno_buffer *buf, git_transfer_progress *stats)
{
int recvd;
@@ -340,8 +339,6 @@ static int no_sideband(git_transport *t, git_indexer_stream *idx, gitno_buffer *
if ((recvd = gitno_recv(buf)) < 0)
return -1;
-
- *bytes += recvd;
} while(recvd > 0);
if (git_indexer_stream_finalize(idx, stats))
@@ -376,7 +373,6 @@ static void network_packetsize(int received, void *payload)
int git_fetch__download_pack(
git_transport *t,
git_repository *repo,
- git_off_t *bytes,
git_transfer_progress *stats,
git_transfer_progress_callback progress_cb,
void *progress_payload)
@@ -403,7 +399,6 @@ int git_fetch__download_pack(
git_buf_free(&path);
memset(stats, 0, sizeof(git_transfer_progress));
- *bytes = 0;
/*
* If the remote doesn't support the side-band, we can feed
@@ -411,7 +406,7 @@ int git_fetch__download_pack(
* check which one belongs there.
*/
if (!t->caps.side_band && !t->caps.side_band_64k) {
- if (no_sideband(t, idx, buf, bytes, stats) < 0)
+ if (no_sideband(t, idx, buf, stats) < 0)
goto on_error;
git_indexer_stream_free(idx);
@@ -438,7 +433,6 @@ int git_fetch__download_pack(
git__free(pkt);
} else if (pkt->type == GIT_PKT_DATA) {
git_pkt_data *p = (git_pkt_data *) pkt;
- *bytes += p->len;
if (git_indexer_stream_add(idx, p->data, p->len, stats) < 0)
goto on_error;
diff --git a/src/fetch.h b/src/fetch.h
index 23d0cf6..5b8c206 100644
--- a/src/fetch.h
+++ b/src/fetch.h
@@ -13,14 +13,12 @@ int git_fetch_negotiate(git_remote *remote);
int git_fetch_download_pack(
git_remote *remote,
- git_off_t *bytes,
git_transfer_progress_callback progress_cb,
void *progress_payload);
int git_fetch__download_pack(
git_transport *t,
git_repository *repo,
- git_off_t *bytes,
git_transfer_progress *stats,
git_transfer_progress_callback progress_cb,
void *progress_payload);
diff --git a/src/remote.c b/src/remote.c
index 3e9a757..87c1ad8 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -435,18 +435,17 @@ int git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void *payload)
int git_remote_download(
git_remote *remote,
- git_off_t *bytes,
git_transfer_progress_callback progress_cb,
void *progress_payload)
{
int error;
- assert(remote && bytes);
+ assert(remote);
if ((error = git_fetch_negotiate(remote)) < 0)
return error;
- return git_fetch_download_pack(remote, bytes, progress_cb, progress_payload);
+ return git_fetch_download_pack(remote, progress_cb, progress_payload);
}
int git_remote_update_tips(git_remote *remote)
diff --git a/src/transport.h b/src/transport.h
index 79afae0..1a3eee5 100644
--- a/src/transport.h
+++ b/src/transport.h
@@ -113,7 +113,7 @@ struct git_transport {
/**
* Download the packfile
*/
- int (*download_pack)(struct git_transport *transport, git_repository *repo, git_off_t *bytes, git_transfer_progress *stats);
+ int (*download_pack)(struct git_transport *transport, git_repository *repo, git_transfer_progress *stats);
/**
* Close the connection
*/
diff --git a/tests-clar/network/fetch.c b/tests-clar/network/fetch.c
index c3fb15e..74e0628 100644
--- a/tests-clar/network/fetch.c
+++ b/tests-clar/network/fetch.c
@@ -38,7 +38,6 @@ static void progress(const git_transfer_progress *stats, void *payload)
static void do_fetch(const char *url, int flag, int n)
{
git_remote *remote;
- git_off_t bytes;
git_remote_callbacks callbacks;
bool progress_was_called = false;
@@ -50,7 +49,7 @@ static void do_fetch(const char *url, int flag, int n)
git_remote_set_callbacks(remote, &callbacks);
git_remote_set_autotag(remote, flag);
cl_git_pass(git_remote_connect(remote, GIT_DIR_FETCH));
- cl_git_pass(git_remote_download(remote, &bytes, progress, &progress_was_called));
+ cl_git_pass(git_remote_download(remote, progress, &progress_was_called));
git_remote_disconnect(remote);
cl_git_pass(git_remote_update_tips(remote));
cl_assert_equal_i(counter, n);