git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] diff.c: flush stdout before printing rename warnings
Date: Tue, 16 Jan 2018 11:06:44 -0800	[thread overview]
Message-ID: <xmqqd129vd17.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20180116092349.11330-1-pclouds@gmail.com> ("Nguyễn Thái Ngọc Duy"'s message of "Tue, 16 Jan 2018 16:23:49 +0700")

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> 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.

The patch sort-of makes sense, and I am not sure if any of the
issues that show rooms for potential improvements I'll mention are
worth doing.

 - This matters only when the standard output and the starndard error
   are going to the same place.  It also would be conceptually nicer to
   flush stderr as well even though it is by default not fully
   buffered.

 - Also this function can take two bools and gives a warning that
   potentially cause the issue three out of four combinations, so one
   out of four cases we would be unnecessarily flushing.



> 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)

  reply	other threads:[~2018-01-16 19:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-16  9:23 [PATCH] diff.c: flush stdout before printing rename warnings Nguyễn Thái Ngọc Duy
2018-01-16 19:06 ` Junio C Hamano [this message]
2018-01-17  1:04   ` Duy Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqd129vd17.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).