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

Re: Bug: "git log --format='format:%+s%+b'" doesn't insert newline before body

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 25, 2016, 07:33 UTC
Message-ID
<alpine.DEB.2.20.1607250926320.14111@virtualbox>
In-Reply-To
<8915446.47C9zkNvuX@photon>
Hi Ilya,
On Sun, 24 Jul 2016, Ilya Tumaykin wrote:
Show 21 quoted lines
> Steps to reproduce:
> $ git init
> $ >123
> $ git add 123
> $ git commit -v -m 'This is subject' -m 'And this is body'
> $ git --no-pager log -1 --format='format:%+s%+b'
> 
> Actual results:
> ```
> 
> This is subject
> And this is body
> ```
> 
> Expected results:
> ```
> 
> This is subject
> 
> And this is body
> ```

The empty line between commit subject and body is neither part of the subject nor of the body. That means that the above-mentioned expectation was incorrect.

Unless you somehow allow empty commit messages (Git does not, unless you play games with low-level commands), the second '+' is unnecessarily conditional. Therefore "%s%n%+b" *might* do what you intended (I would not know, because that information was missing from the report).

Ciao, Johannes

Previous: Beat BolliNext: Ilya Tumaykin
Message 3 of 7 in “Bug: "git log --format='format:%+s%+b'" doesn't insert newline before body”
  1. Ilya TumaykinJul 24, 2016
  2. Beat BolliJul 25, 2016
  3. Johannes SchindelinJul 25, 2016
  4. Ilya TumaykinJul 25, 2016
  5. Johannes SchindelinJul 25, 2016
  6. Ilya TumaykinJul 25, 2016
  7. Jakub NarębskiJul 25, 2016

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.