* MINOR: log-format "%C" & "%+" log
@ 2018-08-22 16:46 Hari Lubovac
2018-08-22 19:07 ` Jeff King
0 siblings, 1 reply; 2+ messages in thread
From: Hari Lubovac @ 2018-08-22 16:46 UTC (permalink / raw)
To: git
Hi -
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..."
Thanks,
Hari
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: MINOR: log-format "%C" & "%+" log
2018-08-22 16:46 MINOR: log-format "%C" & "%+" log Hari Lubovac
@ 2018-08-22 19:07 ` Jeff King
0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2018-08-22 19:07 UTC (permalink / raw)
To: Hari Lubovac; +Cc: git
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-08-22 19:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-22 16:46 MINOR: log-format "%C" & "%+" log Hari Lubovac
2018-08-22 19:07 ` Jeff King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).