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>
Johannes Sixt committed
Nov 19, 2007 at 20:48 UTC
137a0d0ef568f0a2468c8c7f053ef113e295842f
1 file changed
+3
progress.c
+3
@@ -98,11 +98,13 @@ static int display(struct progress *progress, unsigned n, const char *done)
98
fprintf(stderr, "%s: %3u%% (%u/%u)%s%s",
99
progress->title, percent, n,
100
progress->total, tp, eol);
101
+ fflush(stderr);
102
progress_update = 0;
103
return 1;
104
}
105
} else if (progress_update) {
106
fprintf(stderr, "%s: %u%s%s", progress->title, n, tp, eol);
107
+ fflush(stderr);
108
progress_update = 0;
109
return 1;
110
}
@@ -207,6 +209,7 @@ struct progress *start_progress_delay(const char *title, unsigned total,
209
if (!progress) {
210
/* unlikely, but here's a good fallback */
211
fprintf(stderr, "%s...\n", title);
212
+ fflush(stderr);
213
return NULL;
214
}
215
progress->title = title;