summaryrefslogtreecommitdiff
path: root/progress.c
diff options
context:
space:
mode:
Diffstat (limited to 'progress.c')
-rw-r--r--progress.c47
1 files changed, 28 insertions, 19 deletions
diff --git a/progress.c b/progress.c
index 0d44c18edc..8315bdc3d4 100644
--- a/progress.c
+++ b/progress.c
@@ -9,7 +9,7 @@
*/
#define GIT_TEST_PROGRESS_ONLY
-#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "pager.h"
@@ -36,6 +36,7 @@ struct throughput {
};
struct progress {
+ struct repository *repo;
const char *title;
uint64_t last_value;
uint64_t total;
@@ -113,16 +114,19 @@ static void display(struct progress *progress, uint64_t n, const char *done)
const char *tp;
struct strbuf *counters_sb = &progress->counters_sb;
int show_update = 0;
+ int update = !!progress_update;
int last_count_len = counters_sb->len;
- if (progress->delay && (!progress_update || --progress->delay))
+ progress_update = 0;
+
+ if (progress->delay && (!update || --progress->delay))
return;
progress->last_value = n;
tp = (progress->throughput) ? progress->throughput->display.buf : "";
if (progress->total) {
unsigned percent = n * 100 / progress->total;
- if (percent != progress->last_percent || progress_update) {
+ if (percent != progress->last_percent || update) {
progress->last_percent = percent;
strbuf_reset(counters_sb);
@@ -132,7 +136,7 @@ static void display(struct progress *progress, uint64_t n, const char *done)
tp);
show_update = 1;
}
- } else if (progress_update) {
+ } else if (update) {
strbuf_reset(counters_sb);
strbuf_addf(counters_sb, "%"PRIuMAX"%s", (uintmax_t)n, tp);
show_update = 1;
@@ -165,7 +169,6 @@ static void display(struct progress *progress, uint64_t n, const char *done)
}
fflush(stderr);
}
- progress_update = 0;
}
}
@@ -253,10 +256,12 @@ void display_progress(struct progress *progress, uint64_t n)
display(progress, n, NULL);
}
-static struct progress *start_progress_delay(const char *title, uint64_t total,
+static struct progress *start_progress_delay(struct repository *r,
+ const char *title, uint64_t total,
unsigned delay, unsigned sparse)
{
struct progress *progress = xmalloc(sizeof(*progress));
+ progress->repo = r;
progress->title = title;
progress->total = total;
progress->last_value = -1;
@@ -269,7 +274,7 @@ static struct progress *start_progress_delay(const char *title, uint64_t total,
progress->title_len = utf8_strwidth(title);
progress->split = 0;
set_progress_signal();
- trace2_region_enter("progress", title, the_repository);
+ trace2_region_enter("progress", title, r);
return progress;
}
@@ -278,19 +283,21 @@ static int get_default_delay(void)
static int delay_in_secs = -1;
if (delay_in_secs < 0)
- delay_in_secs = git_env_ulong("GIT_PROGRESS_DELAY", 2);
+ delay_in_secs = git_env_ulong("GIT_PROGRESS_DELAY", 1);
return delay_in_secs;
}
-struct progress *start_delayed_progress(const char *title, uint64_t total)
+struct progress *start_delayed_progress(struct repository *r,
+ const char *title, uint64_t total)
{
- return start_progress_delay(title, total, get_default_delay(), 0);
+ return start_progress_delay(r, title, total, get_default_delay(), 0);
}
-struct progress *start_progress(const char *title, uint64_t total)
+struct progress *start_progress(struct repository *r,
+ const char *title, uint64_t total)
{
- return start_progress_delay(title, total, 0, 0);
+ return start_progress_delay(r, title, total, 0, 0);
}
/*
@@ -302,15 +309,17 @@ struct progress *start_progress(const char *title, uint64_t total)
* When "sparse" is set, stop_progress() will automatically force the done
* message to show 100%.
*/
-struct progress *start_sparse_progress(const char *title, uint64_t total)
+struct progress *start_sparse_progress(struct repository *r,
+ const char *title, uint64_t total)
{
- return start_progress_delay(title, total, 0, 1);
+ return start_progress_delay(r, title, total, 0, 1);
}
-struct progress *start_delayed_sparse_progress(const char *title,
+struct progress *start_delayed_sparse_progress(struct repository *r,
+ const char *title,
uint64_t total)
{
- return start_progress_delay(title, total, get_default_delay(), 1);
+ return start_progress_delay(r, title, total, get_default_delay(), 1);
}
static void finish_if_sparse(struct progress *progress)
@@ -340,14 +349,14 @@ static void force_last_update(struct progress *progress, const char *msg)
static void log_trace2(struct progress *progress)
{
- trace2_data_intmax("progress", the_repository, "total_objects",
+ trace2_data_intmax("progress", progress->repo, "total_objects",
progress->total);
if (progress->throughput)
- trace2_data_intmax("progress", the_repository, "total_bytes",
+ trace2_data_intmax("progress", progress->repo, "total_bytes",
progress->throughput->curr_total);
- trace2_region_leave("progress", progress->title, the_repository);
+ trace2_region_leave("progress", progress->title, progress->repo);
}
void stop_progress_msg(struct progress **p_progress, const char *msg)