Re: MINOR: log-format "%C" & "%+" log

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 22, 2018 at 09:46:08AM -0700, Hari Lubovac wrote:

> I don't know where else to report this. It relates to the "log"
> command with "--pretty:format" argument.
> 
> It appears to me that "%C" format argument combined with "%+" or "%-"
> results in no color applied.
> 
> For example, I'd expect the last part of the output line ("%+D") to be
> colored red (it does when the "+" is removed):
> 
> git log --pretty="format:%C(Yellow)%t %C(reset)%ad
> %C(Cyan)%<(6,trunc)%an %C(reset)%s %C(Red)%+D" --date="format:%m/%d"
> 
> This info is taken from https://git-scm.com/docs/pretty-formats: "If
> you add a + (plus sign) after '%' of a placeholder..."

Hmm. I think this is actually due to the way the pager displays colors.

Try this:

  git --no-pager log -1 --format='foo%C(red)%+an'

I see the committer name on its own line in read, as expected. Now try
the same thing with a pager:

  git log -1 --format='foo%C(red)%+an'

I see no color.

The actual output sequence is (<red>, <newline>, <author>). So
presumably what is happening is that the pager does not let color from
the previous line impact to the next line.

Unfortunately I don't know if there's an easy workaround. What you
really want is to apply the "+" magic to a whole section of the string.
You can do that with git-for-each-ref's format, like:

  %(if)%D%(then)%n%C(red)%D%(end)

but the two formats are not (yet) unified. There's interest in doing
that, and an Outreachy intern worked on it over the winter, but there's
still a long way to go.

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux