From 4e056c989f8642050973ba1aabc687979f41798c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Tue, 16 Jan 2018 16:23:49 +0700 Subject: [PATCH] diff.c: flush stdout before printing rename warnings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The diff output is buffered in a FILE object and could still be partially buffered when we print these warnings (directly to fd 2). The output is messed up like this worktree.c | 138 +- worktree.h warning: inexact rename detection was skipped due to too many files. | 12 +- wrapper.c | 83 +- It gets worse if the warning is printed after color codes for the graph part are already printed. You'll get a warning in green or red. Flush stdout first, so we can get something like this instead: xdiff/xutils.c | 42 +- xdiff/xutils.h | 4 +- 1033 files changed, 150824 insertions(+), 69395 deletions(-) warning: inexact rename detection was skipped due to too many files. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- diff.c | 1 + 1 file changed, 1 insertion(+) diff --git a/diff.c b/diff.c index 8c78fce49d..bfd1bd2410 100644 --- a/diff.c +++ b/diff.c @@ -4623,6 +4623,7 @@ static const char rename_limit_advice[] = void diff_warn_rename_limit(const char *varname, int needed, int degraded_cc) { + fflush(stdout); if (degraded_cc) warning(degrade_cc_to_c_warning); else if (needed) -- 2.47.1