diff --git a/remote-curl.c b/remote-curl.c
index 7734495..6b0820e 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -8,6 +8,7 @@
#include "pkt-line.h"
#include "sideband.h"
#include "bundle.h"
+#include "progress.h"
static struct remote *remote;
static const char *url; /* always ends with a trailing slash */
@@ -107,6 +108,9 @@ struct get_refs_cb_data {
int is_bundle;
const char *tmpname;
FILE *fh;
+
+ struct progress *progress;
+ off_t total;
};
static size_t get_refs_callback(char *buf, size_t sz, size_t n, void *vdata)@@ -114,8 +118,11 @@ static size_t get_refs_callback(char *buf, size_t sz, size_t n, void *vdata)
struct get_refs_cb_data *data = vdata;
struct strbuf *out = data->out;
- if (data->is_bundle > 0)
+ if (data->is_bundle > 0) {
+ data->total += sz * n;
+ display_throughput(data->progress, data->total);
return fwrite(buf, sz, n, data->fh);
+ }
strbuf_add(out, buf, sz * n);
@@ -129,6 +136,12 @@ static size_t get_refs_callback(char *buf, size_t sz, size_t n, void *vdata)
die_errno("unable to open %s", data->tmpname);
if (fwrite(out->buf, 1, out->len, data->fh) < out->len)
die_errno("unable to write to %s", data->tmpname);
+ if (options.progress) {
+ data->total = out->len;
+ data->progress = start_progress("Downloading bundle", 0);
+ display_progress(data->progress, 0);
+ display_throughput(data->progress, data->total);
+ }
}
return sz * n;
}@@ -143,6 +156,8 @@ static int get_refs_from_url(const char *url, struct strbuf *out, int options,
data.is_bundle = -1;
data.tmpname = tmpname;
data.fh = NULL;
+ data.progress = NULL;
+ data.total = 0;
ret = http_get_callback(url, get_refs_callback, &data, 0, options);
@@ -150,6 +165,7 @@ static int get_refs_from_url(const char *url, struct strbuf *out, int options,
if (fclose(data.fh))
die_errno("unable to write to %s", data.tmpname);
}
+ stop_progress(&data.progress);
*is_bundle = data.is_bundle > 0;
return ret;--
1.7.7.2.7.g9f96f