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

Re: [PATCH v2] history: streamline message preparation and plug file stream leak

From
Patrick Steinhardt <ps@pks.im>
Date
Jun 30, 2026, 12:24 UTC
Message-ID
<akO1mhi2u2PntLbt@pks.im>
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.

Show 23 quoted lines
> 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
Previous: Junio C Hamano
Message 6 of 6 in “history: streamline message preparation and plug file stream leak”
  1. history: streamline message preparation and plug file stream leakJunio C Hamano, Jun 26, 2026
  2. Patrick SteinhardtJun 29, 2026
  3. Junio C HamanoJun 29, 2026
  4. Patrick SteinhardtJun 29, 2026
  5. history: streamline message preparation and plug file stream leakJunio C Hamano, Jun 29, 2026
  6. Patrick SteinhardtJun 30, 2026

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.