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

Re: git interpret-trailers: behavior with input without trailing newline

From
Jeff King <peff@peff.net>
Date
Jul 13, 2021, 00:35 UTC
Message-ID
<YOzfzQsuDOeL8VY9@coredump.intra.peff.net>
In-Reply-To
<CCNOOVFJVMLC.7L79PCH59K1C@arch-vps>
On Thu, Jul 08, 2021 at 10:33:46AM +0000, Luca Weiss wrote:
Show 7 quoted lines
> I'm investigating a behavior with git interpret-trailers where when
> the input does not end with a newline, git appends the trailer
> directly without a newline; and on running the same command again it
> doesn't detect the previous trailer anymore.
> 
> I've whipped up a quick PoC in form of a new test case in the existing
> test cases of git.

In general, I think commit message inputs should have trailing newlines, as they'd generally be coming from actual commits, or piped through git-stripspace to clean things up.

That said, the behavior you're seeing does seem like a bug to me. I don't think it was intended, and it would be nice to fix it, if you're up for it. It might be as simple as conditionally adding a newline after we read the input in trailers.c:read_input_file(). (IMHO even if we do not end up adding a trailer, normalizing the whitespace in this way would be a fine behavior for the command).

-Peff
Previous: Luca Weiss
Message 2 of 2 in “git interpret-trailers: behavior with input without trailing newline”
  1. Luca WeissJul 8, 2021
  2. Jeff KingJul 13, 2021

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.