summaryrefslogtreecommitdiff
path: root/progress.c
diff options
context:
space:
mode:
authorJohannes Sixt <johannes.sixt@telecom.at>2007-11-19 20:48:58 +0100
committerJunio C Hamano <gitster@pobox.com>2007-11-20 13:16:15 -0800
commit137a0d0ef568f0a2468c8c7f053ef113e295842f (patch)
tree6d68dda1c10a10ac947c7738ff67e9dcbab6662a /progress.c
parent2439755630de90abc9378483e73d3ba54c36ee71 (diff)
downloadgit-137a0d0ef568f0a2468c8c7f053ef113e295842f.tar.gz
Flush progress message buffer in display().
This will make progress display from pack-objects (invoked via upload-pack) more responsive on platforms with an implementation of stdio whose stderr is line buffered. The standard error stream is defined to be merely "not fully buffered"; this is different from "unbuffered". If the implementation of the stdio library chooses to make it line buffered, progress reports that end with CR but do not contain LF will accumulate in the stdio buffer before written out. A fflush() after each progress display gives a nice continuous progress. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'progress.c')
-rw-r--r--progress.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/progress.c b/progress.c
index 4bd650f9ba..d19f80c0bb 100644
--- a/progress.c
+++ b/progress.c
@@ -98,11 +98,13 @@ static int display(struct progress *progress, unsigned n, const char *done)
fprintf(stderr, "%s: %3u%% (%u/%u)%s%s",
progress->title, percent, n,
progress->total, tp, eol);
+ fflush(stderr);
progress_update = 0;
return 1;
}
} else if (progress_update) {
fprintf(stderr, "%s: %u%s%s", progress->title, n, tp, eol);
+ fflush(stderr);
progress_update = 0;
return 1;
}
@@ -207,6 +209,7 @@ struct progress *start_progress_delay(const char *title, unsigned total,
if (!progress) {
/* unlikely, but here's a good fallback */
fprintf(stderr, "%s...\n", title);
+ fflush(stderr);
return NULL;
}
progress->title = title;