From 9d81ecb52b5e6611f66c968884dde42928350b18 Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Thu, 21 Mar 2019 12:36:11 -0700 Subject: progress: add sparse mode to force 100% complete message Add new start_sparse_progress() and start_delayed_sparse_progress() constructors and "sparse" flag to struct progress. Teach stop_progress() to force a 100% complete progress message before printing the final "done" message when "sparse" is set. Calling display_progress() for every item in a large set can be expensive. If callers try to filter this for performance reasons, such as emitting every k-th item, progress would not reach 100% unless they made a final call to display_progress() with the item count before calling stop_progress(). Now this is automatic when "sparse" is set. Signed-off-by: Jeff Hostetler Signed-off-by: Junio C Hamano --- progress.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'progress.h') diff --git a/progress.h b/progress.h index 70a4d4a0d6..7b725acc8d 100644 --- a/progress.h +++ b/progress.h @@ -6,7 +6,10 @@ struct progress; void display_throughput(struct progress *progress, uint64_t total); int display_progress(struct progress *progress, uint64_t n); struct progress *start_progress(const char *title, uint64_t total); +struct progress *start_sparse_progress(const char *title, uint64_t total); struct progress *start_delayed_progress(const char *title, uint64_t total); +struct progress *start_delayed_sparse_progress(const char *title, + uint64_t total); void stop_progress(struct progress **progress); void stop_progress_msg(struct progress **progress, const char *msg); -- cgit v1.2.3