Git development
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH v2] history: streamline message preparation and plug file stream leak
Date: Tue, 30 Jun 2026 14:24:58 +0200	[thread overview]
Message-ID: <akO1mhi2u2PntLbt@pks.im> (raw)
In-Reply-To: <xmqqmrwdxrat.fsf@gitster.g>

On Mon, Jun 29, 2026 at 09:08:42AM -0700, Junio C Hamano wrote:
[snip]
>  * Changes from v1 are two additional error checks to notice failure
>    from fwrite() and fclose() to die.  Interdiff appears at the end.

Technically speaking the first error check for fwrite() should be
unnecessary as the errors accumulate. But it doesn't hurt, either.

> Interdiff against v1:
>   diff --git a/builtin/history.c b/builtin/history.c
>   index f17ec049c0..365e81379b 100644
>   --- a/builtin/history.c
>   +++ b/builtin/history.c
>   @@ -59,13 +59,15 @@ static int fill_commit_message(struct repository *repo,
>    	strbuf_addstr(out, default_message);
>    	strbuf_addch(out, '\n');
>    	strbuf_commented_addf(out, comment_line_str, hint, action, comment_line_str);
>   -	fwrite(out->buf, 1, out->len, s.fp);
>   +	if (fwrite(out->buf, 1, out->len, s.fp) != out->len)
>   +		die_errno(_("could not write to '%s'"), path);
>    
>    	wt_status_collect_changes_trees(&s, old_tree, new_tree);
>    	wt_status_print(&s);
>    	wt_status_collect_free_buffers(&s);
>    	string_list_clear_func(&s.change, change_data_free);
>   -	fclose(s.fp);
>   +	if (fclose(s.fp))
>   +		die_errno(_("could not write to '%s'"), path);
>    
>    	strbuf_reset(out);
>    	if (launch_editor(path, out, NULL)) {

Yup, this looks good to me. Thanks!

Patrick

      reply	other threads:[~2026-06-30 12:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 16:38 [PATCH] history: streamline message preparation and plug file stream leak Junio C Hamano
2026-06-29  6:33 ` Patrick Steinhardt
2026-06-29 15:21   ` Junio C Hamano
2026-06-29 16:04     ` Patrick Steinhardt
2026-06-29 16:08 ` [PATCH v2] " Junio C Hamano
2026-06-30 12:24   ` Patrick Steinhardt [this message]

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

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

  git send-email \
    --in-reply-to=akO1mhi2u2PntLbt@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox