summaryrefslogtreecommitdiff
path: root/progress.c
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2007-04-20 14:10:07 -0400
committerJunio C Hamano <junkio@cox.net>2007-04-22 22:18:05 -0700
commit13aaf148258808437c485d3ef54c7ae7668384d7 (patch)
tree17f2ec24d48906b44948b3091129688ea402f9f7 /progress.c
parent96a02f8f6d2192d3686cd1c719044082c89e8391 (diff)
downloadgit-13aaf148258808437c485d3ef54c7ae7668384d7.tar.gz
make progress "title" part of the common progress interface
If the progress bar ends up in a box, better provide a title for it too. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'progress.c')
-rw-r--r--progress.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/progress.c b/progress.c
index 702e116066..478134bc69 100644
--- a/progress.c
+++ b/progress.c
@@ -40,23 +40,27 @@ int display_progress(struct progress *progress, unsigned n)
if (percent != progress->last_percent || progress_update) {
progress->last_percent = percent;
fprintf(stderr, "%s%4u%% (%u/%u) done\r",
- progress->msg, percent, n, progress->total);
+ progress->prefix, percent, n, progress->total);
progress_update = 0;
return 1;
}
} else if (progress_update) {
- fprintf(stderr, "%s%u\r", progress->msg, n);
+ fprintf(stderr, "%s%u\r", progress->prefix, n);
progress_update = 0;
return 1;
}
return 0;
}
-void start_progress(struct progress *progress, const char *msg, unsigned total)
+void start_progress(struct progress *progress, const char *title,
+ const char *prefix, unsigned total)
{
- progress->msg = msg;
+ char buf[80];
+ progress->prefix = prefix;
progress->total = total;
progress->last_percent = -1;
+ if (snprintf(buf, sizeof(buf), title, total))
+ fprintf(stderr, "%s\n", buf);
set_progress_signal();
}