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

Re: [PATCH] diff: retire sane_truncate_fn

From
Stefan Beller <sbeller@google.com>
Date
Aug 17, 2017, 17:42 UTC
Message-ID
<CAGZ79kZgUCBd0uUjuwvKsUSaAUfpU-wxe6+nVPO_1BXroiCd4w@mail.gmail.com>
In-Reply-To
<xmqq1soahzpb.fsf@gitster.mtv.corp.google.com>
On Thu, Aug 17, 2017 at 10:27 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 18 quoted lines
> Long time ago, 23707811 ("diff: do not chomp hunk-header in the
> middle of a character", 2008-01-02) introduced sane_truncate_line()
> helper function to trim the "function header" line that is shown at
> the end of the hunk header line, in order to avoid chomping it in
> the middle of a single UTF-8 character.  It also added a facility to
> define a custom callback function to make it possible to extend it
> to non UTF-8 encodings.
>
> During the following 8 1/2 years, nobody found need for this custom
> callback facility.
>
> A custom callback function is a wrong design to use here anyway---if
> your contents need support for non UTF-8 encoding, you shouldn't
> have to write a custom function and recompile Git to plumb it in.  A
> better approach would be to extend sane_truncate_line() function and
> have a new member in emit_callback to conditionally trigger it.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This patch is
Reviewed-by: Stefan Beller <sbeller@google.com>

However while strolling around in code nearby, I do wonder if sane_truncate_line needs to make use of the return value of utf8_width. But that is not the case as we're interested in the byte length, not the print length.

Thanks Stefan

Previous: Junio C Hamano
Message 2 of 2 in “diff: retire sane_truncate_fn”
  1. diff: retire sane_truncate_fnJunio C Hamano, Aug 17, 2017
  2. Stefan BellerAug 17, 2017

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.