Skip to content

Commit 137a0d0

Browse files
Johannes Sixtgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2439755 commit 137a0d0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

progress.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ static int display(struct progress *progress, unsigned n, const char *done)
9898
fprintf(stderr, "%s: %3u%% (%u/%u)%s%s",
9999
progress->title, percent, n,
100100
progress->total, tp, eol);
101+
fflush(stderr);
101102
progress_update = 0;
102103
return 1;
103104
}
104105
} else if (progress_update) {
105106
fprintf(stderr, "%s: %u%s%s", progress->title, n, tp, eol);
107+
fflush(stderr);
106108
progress_update = 0;
107109
return 1;
108110
}
@@ -207,6 +209,7 @@ struct progress *start_progress_delay(const char *title, unsigned total,
207209
if (!progress) {
208210
/* unlikely, but here's a good fallback */
209211
fprintf(stderr, "%s...\n", title);
212+
fflush(stderr);
210213
return NULL;
211214
}
212215
progress->title = title;

0 commit comments

Comments
 (0)