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, 08:06 UTC
- Message-ID
- <alpine.DEB.2.20.1607251003360.14111@virtualbox>
- In-Reply-To
- <1693749.WYZjdcdZj5@photon>
Hi Ilya,
On Mon, 25 Jul 2016, Ilya Tumaykin wrote:
Show 17 quoted lines
> On Monday 25 July 2016 09:33:00 Johannes Schindelin wrote: > > > > On Sun, 24 Jul 2016, Ilya Tumaykin wrote: > > [...] > > > $ git --no-pager log -1 --format='format:%+s%+b' > > > > > > Actual results: > > > ``` > > > > > > This is subject > > > And this is body > > > ``` > > According to 'git-log' man page '%+b' should insert linefeed "immediately > before the expansion if and only if the placeholder expands to a non-empty > string." Here "%b" expands to a non-empty string, thus I expect a linefeed > before it. Or am I misinterpreting man page somehow?
The line break is there: after the subject. The misinterpretation is most likely the assumption that the new-line "character" is part of the commit subject; It is not.
Show 10 quoted lines
> > 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). > > I want to display '%B', but add colours to '%s'. Thus I have to > separately include '%s' and '%b', and not just '%B'. I was using > '%+s%n%+b' with extra colour formatting as a workaround for some time > now.
Okay. Hopefully the explanation above clarifies that this is not a work-around, but the correct solution.
Ciao, Johannes