summaryrefslogtreecommitdiff
path: root/src/transports/local.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transports/local.c')
-rw-r--r--src/transports/local.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/transports/local.c b/src/transports/local.c
index 305c71bf0..9dd448681 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -502,6 +502,33 @@ static int foreach_cb(void *buf, size_t len, void *payload)
}
static const char *counting_objects_fmt = "Counting objects %d\r";
+static const char *compressing_objects_fmt = "Compressing objects: %.0f%% (%d/%d)";
+
+static int local_counting(int stage, unsigned int current, unsigned int total, void *payload)
+{
+ git_buf progress_info = GIT_BUF_INIT;
+ transport_local *t = payload;
+
+ if (!t->progress_cb)
+ return 0;
+
+ if (stage == GIT_PACKBUILDER_ADDING_OBJECTS) {
+ git_buf_printf(&progress_info, counting_objects_fmt, current);
+ } else if (stage == GIT_PACKBUILDER_DELTAFICATION) {
+ float perc = (((float) current) / total) * 100;
+ git_buf_printf(&progress_info, compressing_objects_fmt, perc, current, total);
+ if (current == total)
+ git_buf_printf(&progress_info, ", done\n");
+ else
+ git_buf_putc(&progress_info, '\r');
+
+ }
+
+ if (git_buf_oom(&progress_info))
+ return -1;
+
+ return t->progress_cb(git_buf_cstr(&progress_info), git_buf_len(&progress_info), t->message_cb_payload);
+}
static int local_download_pack(
git_transport *transport,
@@ -527,6 +554,8 @@ static int local_download_pack(
if ((error = git_packbuilder_new(&pack, t->repo)) < 0)
goto cleanup;
+ git_packbuilder_set_callbacks(pack, local_counting, t);
+
stats->total_objects = 0;
stats->indexed_objects = 0;
stats->received_objects = 0;