diff options
author | Alex Riesen <raa.lkml@gmail.com> | 2007-05-23 18:07:25 +0200 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-05-23 11:30:49 -0700 |
commit | 421f9d1685b4b7d286b5929489a0d95139c6ecce (patch) | |
tree | 0bd6477728f91fc0fa6d12971f188ea31d2456c8 /progress.c | |
parent | 7ca055f75ad7ffd2251d4b607fbb86d7bcfd77c7 (diff) | |
download | git-421f9d1685b4b7d286b5929489a0d95139c6ecce.tar.gz |
Fix the progress code to output LF only when it is really needed
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'progress.c')
-rw-r--r-- | progress.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/progress.c b/progress.c index 05f7890314..4344f4eed5 100644 --- a/progress.c +++ b/progress.c @@ -62,11 +62,13 @@ int display_progress(struct progress *progress, unsigned n) fprintf(stderr, "%s%4u%% (%u/%u) done\r", progress->prefix, percent, n, progress->total); progress_update = 0; + progress->need_lf = 1; return 1; } } else if (progress_update) { fprintf(stderr, "%s%u\r", progress->prefix, n); progress_update = 0; + progress->need_lf = 1; return 1; } return 0; @@ -80,6 +82,7 @@ void start_progress(struct progress *progress, const char *title, progress->total = total; progress->last_percent = -1; progress->delay = 0; + progress->need_lf = 0; if (snprintf(buf, sizeof(buf), title, total)) fprintf(stderr, "%s\n", buf); set_progress_signal(); @@ -95,12 +98,13 @@ void start_progress_delay(struct progress *progress, const char *title, progress->delayed_percent_treshold = percent_treshold; progress->delayed_title = title; progress->delay = delay; + progress->need_lf = 0; set_progress_signal(); } void stop_progress(struct progress *progress) { clear_progress_signal(); - if (progress->total) + if (progress->need_lf) fputc('\n', stderr); } |