diff options
author | Ben Straub <bs@github.com> | 2012-10-24 13:29:14 -0700 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2012-10-24 13:29:14 -0700 |
commit | 7d222e13121aebc269b2923a66c7ba5b734e1a90 (patch) | |
tree | dbe6ff108dc21d2b2b17e4d4a36d3be454574b4c | |
parent | c4958e6818399f401f03986db8772016a97377d7 (diff) | |
download | libgit2-7d222e13121aebc269b2923a66c7ba5b734e1a90.tar.gz |
Network progress: rename things
git_indexer_stats and friends -> git_transfer_progress*
Also made git_transfer_progress members more sanely
named.
-rw-r--r-- | examples/network/fetch.c | 2 | ||||
-rw-r--r-- | include/git2/clone.h | 4 | ||||
-rw-r--r-- | include/git2/indexer.h | 22 | ||||
-rw-r--r-- | include/git2/remote.h | 4 | ||||
-rw-r--r-- | src/clone.c | 8 | ||||
-rw-r--r-- | src/fetch.c | 20 | ||||
-rw-r--r-- | src/fetch.h | 6 | ||||
-rw-r--r-- | src/index.c | 2 | ||||
-rw-r--r-- | src/indexer.c | 36 | ||||
-rw-r--r-- | src/remote.c | 4 | ||||
-rw-r--r-- | src/remote.h | 2 | ||||
-rw-r--r-- | src/transport.h | 2 | ||||
-rw-r--r-- | tests-clar/clone/network.c | 2 | ||||
-rw-r--r-- | tests-clar/network/fetch.c | 2 | ||||
-rw-r--r-- | tests-clar/pack/packbuilder.c | 2 |
15 files changed, 59 insertions, 59 deletions
diff --git a/examples/network/fetch.c b/examples/network/fetch.c index f7b2fd9de..39cb0deb8 100644 --- a/examples/network/fetch.c +++ b/examples/network/fetch.c @@ -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; diff --git a/include/git2/clone.h b/include/git2/clone.h index 847295a21..7d8d32118 100644 --- a/include/git2/clone.h +++ b/include/git2/clone.h @@ -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); /** @} */ diff --git a/include/git2/indexer.h b/include/git2/indexer.h index ae01fd61d..a2a155473 100644 --- a/include/git2/indexer.h +++ b/include/git2/indexer.h @@ -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. diff --git a/include/git2/remote.h b/include/git2/remote.h index e23997d9a..897dfde8f 100644 --- a/include/git2/remote.h +++ b/include/git2/remote.h @@ -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, diff --git a/src/clone.c b/src/clone.c index 61e5e8567..fc2bfa1fa 100644 --- a/src/clone.c +++ b/src/clone.c @@ -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) { diff --git a/src/fetch.c b/src/fetch.c index 3f69c2cbf..ee85f083d 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -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; /* diff --git a/src/fetch.h b/src/fetch.h index c10973422..23d0cf66f 100644 --- a/src/fetch.h +++ b/src/fetch.h @@ -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); diff --git a/src/index.c b/src/index.c index 362c2c690..f92c48df9 100644 --- a/src/index.c +++ b/src/index.c @@ -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) diff --git a/src/indexer.c b/src/indexer.c index 450d90ebe..4ebcdc6c2 100644 --- a/src/indexer.c +++ b/src/indexer.c @@ -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: diff --git a/src/remote.c b/src/remote.c index 662b8cc9b..3e9a757a5 100644 --- a/src/remote.c +++ b/src/remote.c @@ -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; diff --git a/src/remote.h b/src/remote.h index 1ba82608b..1b382e1bb 100644 --- a/src/remote.h +++ b/src/remote.h @@ -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; diff --git a/src/transport.h b/src/transport.h index 4c944b9e7..79afae000 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_indexer_stats *stats); + int (*download_pack)(struct git_transport *transport, git_repository *repo, git_off_t *bytes, git_transfer_progress *stats); /** * Close the connection */ diff --git a/tests-clar/clone/network.c b/tests-clar/clone/network.c index 3d78d43a3..0faaa5c81 100644 --- a/tests-clar/clone/network.c +++ b/tests-clar/clone/network.c @@ -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; diff --git a/tests-clar/network/fetch.c b/tests-clar/network/fetch.c index 134e8fe2e..c3fb15eb9 100644 --- a/tests-clar/network/fetch.c +++ b/tests-clar/network/fetch.c @@ -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; diff --git a/tests-clar/pack/packbuilder.c b/tests-clar/pack/packbuilder.c index fa7bec14e..6d17a709f 100644 --- a/tests-clar/pack/packbuilder.c +++ b/tests-clar/pack/packbuilder.c @@ -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; |