Commit 7d222e13 by Ben Straub

Network progress: rename things

git_indexer_stats and friends -> git_transfer_progress*

Also made git_transfer_progress members more sanely
named.
parent c4958e68
......@@ -69,7 +69,7 @@ int fetch(git_repository *repo, int argc, char **argv)
{
git_remote *remote = NULL;
git_off_t bytes = 0;
const git_indexer_stats *stats;
const git_transfer_progress *stats;
pthread_t worker;
struct dl_data data;
git_remote_callbacks callbacks;
......
......@@ -42,7 +42,7 @@ GIT_EXTERN(int) git_clone(
git_repository **out,
const char *origin_url,
const char *workdir_path,
git_indexer_progress_callback fetch_progress_cb,
git_transfer_progress_callback fetch_progress_cb,
void *fetch_progress_payload,
git_checkout_opts *checkout_opts);
......@@ -62,7 +62,7 @@ GIT_EXTERN(int) git_clone_bare(
git_repository **out,
const char *origin_url,
const char *dest_path,
git_indexer_progress_callback fetch_progress_cb,
git_transfer_progress_callback fetch_progress_cb,
void *fetch_progress_payload);
/** @} */
......
......@@ -16,18 +16,18 @@ GIT_BEGIN_DECL
* This is passed as the first argument to the callback to allow the
* user to see the progress.
*/
typedef struct git_indexer_stats {
unsigned int total;
unsigned int processed;
unsigned int received;
size_t bytes;
} git_indexer_stats;
typedef struct git_transfer_progress {
unsigned int total_objects;
unsigned int indexed_objects;
unsigned int received_objects;
size_t received_bytes;
} git_transfer_progress;
/**
* Type for progress callbacks during indexing
*/
typedef void (*git_indexer_progress_callback)(const git_indexer_stats *stats, void *payload);
typedef void (*git_transfer_progress_callback)(const git_transfer_progress *stats, void *payload);
typedef struct git_indexer git_indexer;
typedef struct git_indexer_stream git_indexer_stream;
......@@ -43,7 +43,7 @@ typedef struct git_indexer_stream git_indexer_stream;
GIT_EXTERN(int) git_indexer_stream_new(
git_indexer_stream **out,
const char *path,
git_indexer_progress_callback progress_cb,
git_transfer_progress_callback progress_cb,
void *progress_callback_payload);
/**
......@@ -54,7 +54,7 @@ GIT_EXTERN(int) git_indexer_stream_new(
* @param size the size of the data
* @param stats stat storage
*/
GIT_EXTERN(int) git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t size, git_indexer_stats *stats);
GIT_EXTERN(int) git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t size, git_transfer_progress *stats);
/**
* Finalize the pack and index
......@@ -63,7 +63,7 @@ GIT_EXTERN(int) git_indexer_stream_add(git_indexer_stream *idx, const void *data
*
* @param idx the indexer
*/
GIT_EXTERN(int) git_indexer_stream_finalize(git_indexer_stream *idx, git_indexer_stats *stats);
GIT_EXTERN(int) git_indexer_stream_finalize(git_indexer_stream *idx, git_transfer_progress *stats);
/**
* Get the packfile's hash
......@@ -100,7 +100,7 @@ GIT_EXTERN(int) git_indexer_new(git_indexer **out, const char *packname);
* @param idx the indexer instance
* @param stats storage for the running state
*/
GIT_EXTERN(int) git_indexer_run(git_indexer *idx, git_indexer_stats *stats);
GIT_EXTERN(int) git_indexer_run(git_indexer *idx, git_transfer_progress *stats);
/**
* Write the index file to disk.
......
......@@ -194,7 +194,7 @@ 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_indexer_progress_callback progress_cb,
git_transfer_progress_callback progress_cb,
void *progress_payload);
/**
......@@ -325,7 +325,7 @@ GIT_EXTERN(void) git_remote_set_callbacks(git_remote *remote, git_remote_callbac
/**
* Get the statistics structure that is filled in by the fetch operation.
*/
GIT_EXTERN(const git_indexer_stats *) git_remote_stats(git_remote *remote);
GIT_EXTERN(const git_transfer_progress *) git_remote_stats(git_remote *remote);
enum {
GIT_REMOTE_DOWNLOAD_TAGS_UNSET,
......
......@@ -251,7 +251,7 @@ cleanup:
static int setup_remotes_and_fetch(
git_repository *repo,
const char *origin_url,
git_indexer_progress_callback progress_cb,
git_transfer_progress_callback progress_cb,
void *progress_payload)
{
int retcode = GIT_ERROR;
......@@ -310,7 +310,7 @@ static int clone_internal(
git_repository **out,
const char *origin_url,
const char *path,
git_indexer_progress_callback fetch_progress_cb,
git_transfer_progress_callback fetch_progress_cb,
void *fetch_progress_payload,
git_checkout_opts *checkout_opts,
bool is_bare)
......@@ -344,7 +344,7 @@ int git_clone_bare(
git_repository **out,
const char *origin_url,
const char *dest_path,
git_indexer_progress_callback fetch_progress_cb,
git_transfer_progress_callback fetch_progress_cb,
void *fetch_progress_payload)
{
assert(out && origin_url && dest_path);
......@@ -364,7 +364,7 @@ int git_clone(
git_repository **out,
const char *origin_url,
const char *workdir_path,
git_indexer_progress_callback fetch_progress_cb,
git_transfer_progress_callback fetch_progress_cb,
void *fetch_progress_payload,
git_checkout_opts *checkout_opts)
{
......
......@@ -307,7 +307,7 @@ on_error:
int git_fetch_download_pack(
git_remote *remote,
git_off_t *bytes,
git_indexer_progress_callback progress_cb,
git_transfer_progress_callback progress_cb,
void *progress_payload)
{
git_transport *t = remote->transport;
......@@ -323,7 +323,7 @@ int git_fetch_download_pack(
}
static int no_sideband(git_transport *t, git_indexer_stream *idx, gitno_buffer *buf, git_off_t *bytes, git_indexer_stats *stats)
static int no_sideband(git_transport *t, git_indexer_stream *idx, gitno_buffer *buf, git_off_t *bytes, git_transfer_progress *stats)
{
int recvd;
......@@ -352,9 +352,9 @@ static int no_sideband(git_transport *t, git_indexer_stream *idx, gitno_buffer *
struct network_packetsize_payload
{
git_indexer_progress_callback callback;
git_transfer_progress_callback callback;
void *payload;
git_indexer_stats *stats;
git_transfer_progress *stats;
git_off_t last_fired_bytes;
};
......@@ -363,11 +363,11 @@ static void network_packetsize(int received, void *payload)
struct network_packetsize_payload *npp = (struct network_packetsize_payload*)payload;
/* Accumulate bytes */
npp->stats->bytes += received;
npp->stats->received_bytes += received;
/* Fire notification if the threshold is reached */
if ((npp->stats->bytes - npp->last_fired_bytes) > NETWORK_XFER_THRESHOLD) {
npp->last_fired_bytes = npp->stats->bytes;
if ((npp->stats->received_bytes - npp->last_fired_bytes) > NETWORK_XFER_THRESHOLD) {
npp->last_fired_bytes = npp->stats->received_bytes;
npp->callback(npp->stats, npp->payload);
}
}
......@@ -377,8 +377,8 @@ int git_fetch__download_pack(
git_transport *t,
git_repository *repo,
git_off_t *bytes,
git_indexer_stats *stats,
git_indexer_progress_callback progress_cb,
git_transfer_progress *stats,
git_transfer_progress_callback progress_cb,
void *progress_payload)
{
git_buf path = GIT_BUF_INIT;
......@@ -402,7 +402,7 @@ int git_fetch__download_pack(
goto on_error;
git_buf_free(&path);
memset(stats, 0, sizeof(git_indexer_stats));
memset(stats, 0, sizeof(git_transfer_progress));
*bytes = 0;
/*
......
......@@ -14,15 +14,15 @@ int git_fetch_negotiate(git_remote *remote);
int git_fetch_download_pack(
git_remote *remote,
git_off_t *bytes,
git_indexer_progress_callback progress_cb,
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_indexer_stats *stats,
git_indexer_progress_callback progress_cb,
git_transfer_progress *stats,
git_transfer_progress_callback progress_cb,
void *progress_payload);
int git_fetch_setup_walk(git_revwalk **out, git_repository *repo);
......
......@@ -1034,7 +1034,7 @@ int git_index_entry_stage(const git_index_entry *entry)
typedef struct read_tree_data {
git_index *index;
git_indexer_stats *stats;
git_transfer_progress *stats;
} read_tree_data;
static int read_tree_cb(const char *root, const git_tree_entry *tentry, void *data)
......
......@@ -49,7 +49,7 @@ struct git_indexer_stream {
git_vector deltas;
unsigned int fanout[256];
git_oid hash;
git_indexer_progress_callback progress_cb;
git_transfer_progress_callback progress_cb;
void *progress_payload;
};
......@@ -143,7 +143,7 @@ static int cache_cmp(const void *a, const void *b)
int git_indexer_stream_new(
git_indexer_stream **out,
const char *prefix,
git_indexer_progress_callback progress_cb,
git_transfer_progress_callback progress_cb,
void *progress_payload)
{
git_indexer_stream *idx;
......@@ -281,13 +281,13 @@ on_error:
return -1;
}
static void do_progress_callback(git_indexer_stream *idx, git_indexer_stats *stats)
static void do_progress_callback(git_indexer_stream *idx, git_transfer_progress *stats)
{
if (!idx->progress_cb) return;
idx->progress_cb(stats, idx->progress_payload);
}
int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t size, git_indexer_stats *stats)
int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t size, git_transfer_progress *stats)
{
int error;
struct git_pack_header hdr;
......@@ -296,7 +296,7 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
assert(idx && data && stats);
processed = stats->processed;
processed = stats->indexed_objects;
if (git_filebuf_write(&idx->pack_file, data, size) < 0)
return -1;
......@@ -338,8 +338,8 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
if (git_vector_init(&idx->deltas, (unsigned int)(idx->nr_objects / 2), NULL) < 0)
return -1;
memset(stats, 0, sizeof(git_indexer_stats));
stats->total = (unsigned int)idx->nr_objects;
memset(stats, 0, sizeof(git_transfer_progress));
stats->total_objects = (unsigned int)idx->nr_objects;
do_progress_callback(idx, stats);
}
......@@ -376,7 +376,7 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
if (error < 0)
return error;
stats->received++;
stats->received_objects++;
do_progress_callback(idx, stats);
continue;
}
......@@ -395,8 +395,8 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
git__free(obj.data);
stats->processed = (unsigned int)++processed;
stats->received++;
stats->indexed_objects = (unsigned int)++processed;
stats->received_objects++;
do_progress_callback(idx, stats);
}
......@@ -429,7 +429,7 @@ static int index_path_stream(git_buf *path, git_indexer_stream *idx, const char
return git_buf_oom(path) ? -1 : 0;
}
static int resolve_deltas(git_indexer_stream *idx, git_indexer_stats *stats)
static int resolve_deltas(git_indexer_stream *idx, git_transfer_progress *stats)
{
unsigned int i;
struct delta_info *delta;
......@@ -445,14 +445,14 @@ static int resolve_deltas(git_indexer_stream *idx, git_indexer_stats *stats)
return -1;
git__free(obj.data);
stats->processed++;
stats->indexed_objects++;
do_progress_callback(idx, stats);
}
return 0;
}
int git_indexer_stream_finalize(git_indexer_stream *idx, git_indexer_stats *stats)
int git_indexer_stream_finalize(git_indexer_stream *idx, git_transfer_progress *stats)
{
git_mwindow *w = NULL;
unsigned int i, long_offsets = 0, left;
......@@ -473,7 +473,7 @@ int git_indexer_stream_finalize(git_indexer_stream *idx, git_indexer_stats *stat
if (resolve_deltas(idx, stats) < 0)
return -1;
if (stats->processed != stats->total) {
if (stats->indexed_objects != stats->total_objects) {
giterr_set(GITERR_INDEXER, "Indexing error: early EOF");
return -1;
}
......@@ -800,7 +800,7 @@ cleanup:
return error;
}
int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
int git_indexer_run(git_indexer *idx, git_transfer_progress *stats)
{
git_mwindow_file *mwf;
git_off_t off = sizeof(struct git_pack_header);
......@@ -815,8 +815,8 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
if (error < 0)
return error;
stats->total = (unsigned int)idx->nr_objects;
stats->processed = processed = 0;
stats->total_objects = (unsigned int)idx->nr_objects;
stats->indexed_objects = processed = 0;
while (processed < idx->nr_objects) {
git_rawobj obj;
......@@ -886,7 +886,7 @@ int git_indexer_run(git_indexer *idx, git_indexer_stats *stats)
git__free(obj.data);
stats->processed = ++processed;
stats->indexed_objects = ++processed;
}
cleanup:
......
......@@ -436,7 +436,7 @@ 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_indexer_progress_callback progress_cb,
git_transfer_progress_callback progress_cb,
void *progress_payload)
{
int error;
......@@ -707,7 +707,7 @@ void git_remote_set_callbacks(git_remote *remote, git_remote_callbacks *callback
}
}
inline const git_indexer_stats* git_remote_stats(git_remote *remote)
inline const git_transfer_progress* git_remote_stats(git_remote *remote)
{
assert(remote);
return &remote->stats;
......
......@@ -25,7 +25,7 @@ struct git_remote {
git_transport *transport;
git_repository *repo;
git_remote_callbacks callbacks;
git_indexer_stats stats;
git_transfer_progress stats;
unsigned int need_pack:1,
download_tags:2, /* There are four possible values */
check_cert:1;
......
......@@ -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_indexer_stats *stats);
int (*download_pack)(struct git_transport *transport, git_repository *repo, git_off_t *bytes, git_transfer_progress *stats);
/**
* Close the connection
*/
......
......@@ -98,7 +98,7 @@ static void checkout_progress(const char *path, size_t cur, size_t tot, void *pa
(*was_called) = true;
}
static void fetch_progress(const git_indexer_stats *stats, void *payload)
static void fetch_progress(const git_transfer_progress *stats, void *payload)
{
GIT_UNUSED(stats);
bool *was_called = (bool*)payload;
......
......@@ -28,7 +28,7 @@ static int update_tips(const char *refname, const git_oid *a, const git_oid *b,
return 0;
}
static void progress(const git_indexer_stats *stats, void *payload)
static void progress(const git_transfer_progress *stats, void *payload)
{
GIT_UNUSED(stats);
bool *was_called = (bool*)payload;
......
......@@ -33,7 +33,7 @@ void test_pack_packbuilder__cleanup(void)
void test_pack_packbuilder__create_pack(void)
{
git_indexer_stats stats;
git_transfer_progress stats;
git_oid oid, *o;
unsigned int i;
......
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