Harry Jeffery [off-list ref] writes:
Add a new format prefix `_` that causes a line-feed to be inserted
immediately after an expansion if the expansion expands to a non-empty
string. This is useful for when you would like a line for an expansion
to be prepended, but only when the expansion expands to a non empty
string, such as inserting a '%_d' expansion before a commit to show any
refs pointing towards it.
Is this different from "%n%-d"?
On 09/09/14 20:15, Junio C Hamano wrote:
Is this different from "%n%-d"?
Yes. "%n%-d" will place the newline before the expansion, not after.
log --decorate --pretty=format:"%n%-d%h\\ %t\\ [%cn]\\ %s"
---
(HEAD, upstream/master, master)85f0837 c29da1d [Junio C Hamano] Start
the post-2.1 cycle
f655651 4027a43 [Junio C Hamano] Merge branch 'rs/strbuf-getcwd'
51eeaea 1f4970c [Junio C Hamano] Merge branch 'ta/pretty-parse-config'
4740891 8961621 [Junio C Hamano] Merge branch 'bc/archive-pax-header-mode'
---
log --decorate --pretty=format:"%_d%%h\\ %t\\ [%cn]\\ %s"
---
(HEAD, upstream/master, master)
85f0837 c29da1d [Junio C Hamano] Start the post-2.1 cycle
f655651 4027a43 [Junio C Hamano] Merge branch 'rs/strbuf-getcwd'
51eeaea 1f4970c [Junio C Hamano] Merge branch 'ta/pretty-parse-config'
4740891 8961621 [Junio C Hamano] Merge branch 'bc/archive-pax-header-mode'
---
The latter is the output I've been trying to accomplish, and as far as I
can tell, this patch is the only way to achieve it.
Well, you can do "%d%n" but that will put a blank line before every
commit that doesn't have a ref.