git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] diff.c: flush stdout before printing rename warnings

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jan 16, 2018, 09:23 UTC
Message-ID
<20180116092349.11330-1-pclouds@gmail.com>

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 <pclouds@gmail.com>
---
 diff.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/diff.c b/diff.c
index fb22b19f09..5545c25640 100644
--- a/diff.c
+++ b/diff.c
@@ -5454,6 +5454,7 @@ N_("you may want to set your %s variable to at least "
 
 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.15.1.600.g899a5f85c6
Next: Junio C Hamano
Message 1 of 3 in “diff.c: flush stdout before printing rename warnings”
  1. diff.c: flush stdout before printing rename warningsNguyễn Thái Ngọc Duy, Jan 16, 2018
  2. Junio C HamanoJan 16, 2018
  3. Duy NguyenJan 17, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.