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

Re: [PATCH] mailmap: handle mailmap blobs without trailing newlines

From
Jeff King <peff@peff.net>
Date
Aug 25, 2013, 08:55 UTC
Message-ID
<20130825085500.GA6089@sigill.intra.peff.net>
In-Reply-To
<20130825084549.GA5912@sigill.intra.peff.net>
On Sun, Aug 25, 2013 at 04:45:50AM -0400, Jeff King wrote:
Show 5 quoted lines
> This is the minimal fix. Another option would be to switch
> read_mailmap_buf to read_mailmap_string, and I think we could even get
> away with avoiding the extra allocation/copy in the loop (because
> read_mailmap_line seems to cope with newline-or-EOS just fine). But it
> may be better to save that for 'master'.

Hmm, actually, this isn't quite true. read_mailmap_line does handle the optional trailing newline properly, but the underlying parsing routines really do want to see a NUL at the end of each line (because they came from code that just calls fgets). So we really do want to tie off each line. But given that our only caller is handing us blob contents which get immediately freed, we could still do that without an extra allocation if:

  1. We make it clear that the input must be NUL-terminated (i.e., by
     renaming the function and dropping the len parameter).
  2. We drop the "const" from the buf parameter so that we can simply
     terminate each line as we go.
I'll see what the patch looks like.
-Peff
Previous: Jeff KingNext: Jeff King
Message 2 of 3 in “mailmap: handle mailmap blobs without trailing newlines”
  1. mailmap: handle mailmap blobs without trailing newlinesJeff King, Aug 25, 2013
  2. Jeff KingAug 25, 2013
  3. Jeff KingAug 25, 2013

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.