diff options
author | Vicent Martà <vicent@github.com> | 2012-08-24 16:29:01 -0700 |
---|---|---|
committer | Vicent Martà <vicent@github.com> | 2012-08-24 16:29:01 -0700 |
commit | b7e8827b8bbca0c69d85be34cc4a88888c1152f2 (patch) | |
tree | f55dad3e7af50329b1a00a943035d1ebf4cb0def /examples/network/fetch.c | |
parent | 09fad5069636fb2e8cacf15817834e3d32ff6b8e (diff) | |
parent | 0a1db746fbcaf09681e446250f75581cc8f8fd05 (diff) | |
download | libgit2-b7e8827b8bbca0c69d85be34cc4a88888c1152f2.tar.gz |
Merge pull request #895 from carlosmn/sideband
Add sideband support
Diffstat (limited to 'examples/network/fetch.c')
-rw-r--r-- | examples/network/fetch.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/examples/network/fetch.c b/examples/network/fetch.c index 52e0412f..fa941b97 100644 --- a/examples/network/fetch.c +++ b/examples/network/fetch.c @@ -14,6 +14,13 @@ struct dl_data { int finished; }; +static void progress_cb(const char *str, int len, void *data) +{ + data = data; + printf("remote: %.*s", len, str); + fflush(stdout); /* We don't have the \n to force the flush */ +} + static void *download(void *ptr) { struct dl_data *data = (struct dl_data *)ptr; @@ -43,6 +50,7 @@ exit: static int update_cb(const char *refname, const git_oid *a, const git_oid *b, void *data) { char a_str[GIT_OID_HEXSZ+1], b_str[GIT_OID_HEXSZ+1]; + data = data; git_oid_fmt(b_str, b); b_str[GIT_OID_HEXSZ] = '\0'; @@ -78,6 +86,7 @@ int fetch(git_repository *repo, int argc, char **argv) // Set up the callbacks (only update_tips for now) memset(&callbacks, 0, sizeof(callbacks)); callbacks.update_tips = &update_cb; + callbacks.progress = &progress_cb; git_remote_set_callbacks(remote, &callbacks); // Set up the information for the background worker thread @@ -96,7 +105,10 @@ int fetch(git_repository *repo, int argc, char **argv) // the download rate. do { usleep(10000); - printf("\rReceived %d/%d objects in %zu bytes", stats.processed, stats.total, bytes); + + if (stats.total > 0) + printf("Received %d/%d objects (%d) in %d bytes\r", + stats.received, stats.total, stats.processed, bytes); } while (!data.finished); if (data.ret < 0) |