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

bug: git format prints no final newline

From
EBEvan Benn <evanbenn@google.com>
Date
Nov 3, 2022, 03:14 UTC
Message-ID
<CAKz_xw2X+eapmASqG7V=RXehh7=LN24m+MJPn-wx80oZAZHBnQ@mail.gmail.com>
This command omits the final newline:
git log --format=format:"%H"
check with: `| tail | cat -A`
This command doesn't, but there is an extra newline between each line of course:
git log --format=format:"%H%n"

This seems to be intentional in the code, a newline is printed before each line except the first:

https://github.com/git/git/blob/master/log-tree.c#L664

It seems more correct to print a newline after every line, but the code is very hairy so I am keen to get any feedback before attempting that.

Thanks
Next: Jeff King
Message 1 of 2 in “bug: git format prints no final newline”
  1. Evan BennNov 3, 2022
  2. Jeff KingNov 3, 2022

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.