Bug: "git log --format='format:%+s%+b'" doesn't insert newline before body
Hello.
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 ```
$ git --version git version 2.9.2
Please fix.
Signature · 2 lines
Best regards. Ilya Tumaykin.
Re: Bug:
Quoted 2 lines · Ilya Tumaykin <itumaykin <at> gmail.com> writes:
$ git --no-pager log -1 --format='format:%+s%+b' Please fix.
Simply use git --no-pager log -1 --format='format:%+s%n%+b'
The message body excludes the empty line preceding it.
Hi Ilya,
Quoted 14 lines · Ilya Tumaykin
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 ```
Quoted 7 lines
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
Quoted 20 lines · On Monday 25 July 2016 09:33:00 Johannes Schindelin wrote:
Hi Ilya,
Quoted 17 lines · Ilya Tumaykin
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:
```
Quoted 8 lines
Quoted 4 lines
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.
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?
Quoted 4 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.
Quoted 2 lines
Ciao,
Johannes
Signature · 2 lines
Best regards. Ilya Tumaykin.
Hi Ilya,
Quoted 9 lines · Ilya Tumaykin
Quoted 8 lines · On Monday 25 July 2016 09:33:00 Johannes Schindelin wrote:
On Sun, 24 Jul 2016, Ilya Tumaykin wrote:
[...]Quoted 5 lines
$ git --no-pager log -1 --format='format:%+s%+b'Actual results:
```
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
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.
Quoted 10 lines
Quoted 5 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
Quoted 16 lines · On Monday 25 July 2016 10:06:28 Johannes Schindelin wrote:
Hi Ilya,
Quoted 13 lines · Ilya Tumaykin
Quoted 11 lines · On Monday 25 July 2016 09:33:00 Johannes Schindelin wrote:
On Sun, 24 Jul 2016, Ilya Tumaykin wrote:
[...]Quoted 8 lines
$ git --no-pager log -1 --format='format:%+s%+b'Actual results:
``` This is subject And this is body ```
Quoted 8 lines
Quoted 4 lines
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.
I see. Thank you very much for the explanation. This does help me.
Signature · 2 lines
Best regards. Ilya Tumaykin.
W dniu 2016-07-25 o 09:33, Johannes Schindelin pisze:
Quoted 2 lines
Therefore "%s%n%+b" *might* do what you intended (I would not know, because that information was missing from the report).
Shouldn't it be "%s%n%n%-b" or "%s%n%-b"?
Signature · 1 line
Jakub Narębski