Commit 1e3b8ed5 by Ben Straub

Remove 'bytes' param from git_remote_download

parent 9762ad99
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
struct dl_data { struct dl_data {
git_remote *remote; git_remote *remote;
git_off_t *bytes;
int ret; int ret;
int finished; int finished;
}; };
...@@ -34,7 +33,7 @@ static void *download(void *ptr) ...@@ -34,7 +33,7 @@ static void *download(void *ptr)
// Download the packfile and index it. This function updates the // Download the packfile and index it. This function updates the
// amount of received data and the indexer stats which lets you // amount of received data and the indexer stats which lets you
// inform the user about progress. // 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; data->ret = -1;
goto exit; goto exit;
} }
...@@ -68,7 +67,6 @@ static int update_cb(const char *refname, const git_oid *a, const git_oid *b, vo ...@@ -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) int fetch(git_repository *repo, int argc, char **argv)
{ {
git_remote *remote = NULL; git_remote *remote = NULL;
git_off_t bytes = 0;
const git_transfer_progress *stats; const git_transfer_progress *stats;
pthread_t worker; pthread_t worker;
struct dl_data data; struct dl_data data;
...@@ -90,7 +88,6 @@ int fetch(git_repository *repo, int argc, char **argv) ...@@ -90,7 +88,6 @@ int fetch(git_repository *repo, int argc, char **argv)
// Set up the information for the background worker thread // Set up the information for the background worker thread
data.remote = remote; data.remote = remote;
data.bytes = &bytes;
data.ret = 0; data.ret = 0;
data.finished = 0; data.finished = 0;
...@@ -108,7 +105,7 @@ int fetch(git_repository *repo, int argc, char **argv) ...@@ -108,7 +105,7 @@ int fetch(git_repository *repo, int argc, char **argv)
if (stats->total_objects > 0) if (stats->total_objects > 0)
printf("Received %d/%d objects (%d) in %d bytes\r", printf("Received %d/%d objects (%d) in %d bytes\r",
stats->received_objects, stats->total_objects, stats->received_objects, stats->total_objects,
stats->indexed_objects, bytes); stats->indexed_objects, stats->received_bytes);
} while (!data.finished); } while (!data.finished);
if (data.ret < 0) if (data.ret < 0)
...@@ -116,7 +113,7 @@ int fetch(git_repository *repo, int argc, char **argv) ...@@ -116,7 +113,7 @@ int fetch(git_repository *repo, int argc, char **argv)
pthread_join(worker, NULL); pthread_join(worker, NULL);
printf("\rReceived %d/%d objects in %zu bytes\n", 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. // Disconnect the underlying connection to prevent from idling.
git_remote_disconnect(remote); git_remote_disconnect(remote);
......
...@@ -183,8 +183,6 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void ...@@ -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. * filename will be NULL and the function will return success.
* *
* @param remote the remote to download from * @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 * @param progress_cb function to call with progress information. Be aware that
* this is called inline with network and indexing operations, so performance * this is called inline with network and indexing operations, so performance
* may be affected. * may be affected.
...@@ -193,7 +191,6 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void ...@@ -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_EXTERN(int) git_remote_download(
git_remote *remote, git_remote *remote,
git_off_t *bytes,
git_transfer_progress_callback progress_cb, git_transfer_progress_callback progress_cb,
void *progress_payload); void *progress_payload);
......
...@@ -256,13 +256,12 @@ static int setup_remotes_and_fetch( ...@@ -256,13 +256,12 @@ static int setup_remotes_and_fetch(
{ {
int retcode = GIT_ERROR; int retcode = GIT_ERROR;
git_remote *origin = NULL; git_remote *origin = NULL;
git_off_t bytes = 0;
/* Create the "origin" remote */ /* Create the "origin" remote */
if (!git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, origin_url)) { if (!git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, origin_url)) {
/* Connect and download everything */ /* Connect and download everything */
if (!git_remote_connect(origin, GIT_DIR_FETCH)) { 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 */ /* Create "origin/foo" branches for all remote branches */
if (!git_remote_update_tips(origin)) { if (!git_remote_update_tips(origin)) {
/* Point HEAD to the same ref as the remote's head */ /* Point HEAD to the same ref as the remote's head */
......
...@@ -306,7 +306,6 @@ on_error: ...@@ -306,7 +306,6 @@ on_error:
int git_fetch_download_pack( int git_fetch_download_pack(
git_remote *remote, git_remote *remote,
git_off_t *bytes,
git_transfer_progress_callback progress_cb, git_transfer_progress_callback progress_cb,
void *progress_payload) void *progress_payload)
{ {
...@@ -316,14 +315,14 @@ int git_fetch_download_pack( ...@@ -316,14 +315,14 @@ int git_fetch_download_pack(
return 0; return 0;
if (t->own_logic) 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); 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; int recvd;
...@@ -340,8 +339,6 @@ static int no_sideband(git_transport *t, git_indexer_stream *idx, gitno_buffer * ...@@ -340,8 +339,6 @@ static int no_sideband(git_transport *t, git_indexer_stream *idx, gitno_buffer *
if ((recvd = gitno_recv(buf)) < 0) if ((recvd = gitno_recv(buf)) < 0)
return -1; return -1;
*bytes += recvd;
} while(recvd > 0); } while(recvd > 0);
if (git_indexer_stream_finalize(idx, stats)) if (git_indexer_stream_finalize(idx, stats))
...@@ -376,7 +373,6 @@ static void network_packetsize(int received, void *payload) ...@@ -376,7 +373,6 @@ static void network_packetsize(int received, void *payload)
int git_fetch__download_pack( int git_fetch__download_pack(
git_transport *t, git_transport *t,
git_repository *repo, git_repository *repo,
git_off_t *bytes,
git_transfer_progress *stats, git_transfer_progress *stats,
git_transfer_progress_callback progress_cb, git_transfer_progress_callback progress_cb,
void *progress_payload) void *progress_payload)
...@@ -403,7 +399,6 @@ int git_fetch__download_pack( ...@@ -403,7 +399,6 @@ int git_fetch__download_pack(
git_buf_free(&path); git_buf_free(&path);
memset(stats, 0, sizeof(git_transfer_progress)); memset(stats, 0, sizeof(git_transfer_progress));
*bytes = 0;
/* /*
* If the remote doesn't support the side-band, we can feed * If the remote doesn't support the side-band, we can feed
...@@ -411,7 +406,7 @@ int git_fetch__download_pack( ...@@ -411,7 +406,7 @@ int git_fetch__download_pack(
* check which one belongs there. * check which one belongs there.
*/ */
if (!t->caps.side_band && !t->caps.side_band_64k) { 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; goto on_error;
git_indexer_stream_free(idx); git_indexer_stream_free(idx);
...@@ -438,7 +433,6 @@ int git_fetch__download_pack( ...@@ -438,7 +433,6 @@ int git_fetch__download_pack(
git__free(pkt); git__free(pkt);
} else if (pkt->type == GIT_PKT_DATA) { } else if (pkt->type == GIT_PKT_DATA) {
git_pkt_data *p = (git_pkt_data *) pkt; git_pkt_data *p = (git_pkt_data *) pkt;
*bytes += p->len;
if (git_indexer_stream_add(idx, p->data, p->len, stats) < 0) if (git_indexer_stream_add(idx, p->data, p->len, stats) < 0)
goto on_error; goto on_error;
......
...@@ -13,14 +13,12 @@ int git_fetch_negotiate(git_remote *remote); ...@@ -13,14 +13,12 @@ int git_fetch_negotiate(git_remote *remote);
int git_fetch_download_pack( int git_fetch_download_pack(
git_remote *remote, git_remote *remote,
git_off_t *bytes,
git_transfer_progress_callback progress_cb, git_transfer_progress_callback progress_cb,
void *progress_payload); void *progress_payload);
int git_fetch__download_pack( int git_fetch__download_pack(
git_transport *t, git_transport *t,
git_repository *repo, git_repository *repo,
git_off_t *bytes,
git_transfer_progress *stats, git_transfer_progress *stats,
git_transfer_progress_callback progress_cb, git_transfer_progress_callback progress_cb,
void *progress_payload); void *progress_payload);
......
...@@ -435,18 +435,17 @@ int git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void *payload) ...@@ -435,18 +435,17 @@ int git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void *payload)
int git_remote_download( int git_remote_download(
git_remote *remote, git_remote *remote,
git_off_t *bytes,
git_transfer_progress_callback progress_cb, git_transfer_progress_callback progress_cb,
void *progress_payload) void *progress_payload)
{ {
int error; int error;
assert(remote && bytes); assert(remote);
if ((error = git_fetch_negotiate(remote)) < 0) if ((error = git_fetch_negotiate(remote)) < 0)
return error; 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) int git_remote_update_tips(git_remote *remote)
......
...@@ -113,7 +113,7 @@ struct git_transport { ...@@ -113,7 +113,7 @@ struct git_transport {
/** /**
* Download the packfile * 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 * Close the connection
*/ */
......
...@@ -38,7 +38,6 @@ static void progress(const git_transfer_progress *stats, void *payload) ...@@ -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) static void do_fetch(const char *url, int flag, int n)
{ {
git_remote *remote; git_remote *remote;
git_off_t bytes;
git_remote_callbacks callbacks; git_remote_callbacks callbacks;
bool progress_was_called = false; bool progress_was_called = false;
...@@ -50,7 +49,7 @@ static void do_fetch(const char *url, int flag, int n) ...@@ -50,7 +49,7 @@ static void do_fetch(const char *url, int flag, int n)
git_remote_set_callbacks(remote, &callbacks); git_remote_set_callbacks(remote, &callbacks);
git_remote_set_autotag(remote, flag); git_remote_set_autotag(remote, flag);
cl_git_pass(git_remote_connect(remote, GIT_DIR_FETCH)); 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); git_remote_disconnect(remote);
cl_git_pass(git_remote_update_tips(remote)); cl_git_pass(git_remote_update_tips(remote));
cl_assert_equal_i(counter, n); cl_assert_equal_i(counter, n);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment