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

Re: [PATCH v1] convert log_ref_write_fd() to use strbuf

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 10, 2018, 19:41 UTC
Message-ID
<xmqqsh4q6fpb.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180710184534.GA27535@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 14 quoted lines
>> -	while (buf < cp && isspace(cp[-1]))
>> -		cp--;
>> -	*cp++ = '\n';
>> -	return cp - buf;
>> +	strbuf_rtrim(sb);
>
> Using rtrim is a nice reduction in complexity. A pure translation would
> include a final strbuf_addch(sb, '\n'). It looks like you moved that to
> the caller. There's only one, so that's OK now, but it may affect topics
> in flight (and I do in fact have an old topic that calls it).
>
> But I think it's OK, as the change in function signature means that any
> callers will need updated anyway. So there's little risk of a silent
> mis-merge.

It is interesting that we came to a slightly different conclusion, after doing pretty much the same analysis ;-). Unless Ben has a plan to use a version that trims the trailing LF elsewhere, there is no point changing what the function does, especially because the existing and only caller does want the terminating LF at the end.

Previous: Jeff KingNext: Jeff King
Message 3 of 8 in “convert log_ref_write_fd() to use strbuf”
  1. convert log_ref_write_fd() to use strbufBen Peart, Jul 10, 2018
  2. Jeff KingJul 10, 2018
  3. Junio C HamanoJul 10, 2018
  4. Jeff KingJul 10, 2018
  5. Ben PeartJul 10, 2018
  6. convert log_ref_write_fd() to use strbufBen Peart, Jul 10, 2018
  7. Junio C HamanoJul 10, 2018
  8. brian m. carlsonJul 13, 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.