{"thread":{"id":"49193","subject":"MINOR: log-format \"%C\" & \"%+\" log","startedAt":"2018-08-22T16:46:22Z","lastAt":"2018-08-22T19:07:21Z","messageCount":2,"participants":["Hari Lubovac","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"356281","messageId":"CAFLu24kbCJu74tgfRDR=xPZ3pkbau9R6jmqPbFKR=ZnWOvbCvQ@mail.gmail.com","threadId":"49193","inReplyTo":null,"subject":"MINOR: log-format \"%C\" & \"%+\" log","fromName":"Hari Lubovac","fromEmail":"hlubovac@gmail.com","sentAt":"2018-08-22T16:46:08Z","receivedAt":"2018-08-22T16:46:22Z","isPatch":false,"sender":{"key":"hlubovac@gmail.com","avatar":"https://gravatar.com/avatar/7dab36f50a4265fbffed080c731347c7c789e745e6225b701bc16eb54b8ae9c1?d=mp&s=160"},"body":"Hi -\n\nI don't know where else to report this. It relates to the \"log\"\ncommand with \"--pretty:format\" argument.\n\nIt appears to me that \"%C\" format argument combined with \"%+\" or \"%-\"\nresults in no color applied.\n\nFor example, I'd expect the last part of the output line (\"%+D\") to be\ncolored red (it does when the \"+\" is removed):\n\ngit log --pretty=\"format:%C(Yellow)%t %C(reset)%ad\n%C(Cyan)%<(6,trunc)%an %C(reset)%s %C(Red)%+D\" --date=\"format:%m/%d\"\n\nThis info is taken from https://git-scm.com/docs/pretty-formats: \"If\nyou add a + (plus sign) after '%' of a placeholder...\"\n\nThanks,\nHari\n"},{"id":"356299","messageId":"20180822190718.GA19730@sigill.intra.peff.net","threadId":"49193","inReplyTo":"CAFLu24kbCJu74tgfRDR=xPZ3pkbau9R6jmqPbFKR=ZnWOvbCvQ@mail.gmail.com","subject":"Re: MINOR: log-format \"%C\" & \"%+\" log","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2018-08-22T19:07:18Z","receivedAt":"2018-08-22T19:07:21Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Aug 22, 2018 at 09:46:08AM -0700, Hari Lubovac wrote:\n\n> I don't know where else to report this. It relates to the \"log\"\n> command with \"--pretty:format\" argument.\n> \n> It appears to me that \"%C\" format argument combined with \"%+\" or \"%-\"\n> results in no color applied.\n> \n> For example, I'd expect the last part of the output line (\"%+D\") to be\n> colored red (it does when the \"+\" is removed):\n> \n> git log --pretty=\"format:%C(Yellow)%t %C(reset)%ad\n> %C(Cyan)%<(6,trunc)%an %C(reset)%s %C(Red)%+D\" --date=\"format:%m/%d\"\n> \n> This info is taken from https://git-scm.com/docs/pretty-formats: \"If\n> you add a + (plus sign) after '%' of a placeholder...\"\n\nHmm. I think this is actually due to the way the pager displays colors.\n\nTry this:\n\n  git --no-pager log -1 --format='foo%C(red)%+an'\n\nI see the committer name on its own line in read, as expected. Now try\nthe same thing with a pager:\n\n  git log -1 --format='foo%C(red)%+an'\n\nI see no color.\n\nThe actual output sequence is (<red>, <newline>, <author>). So\npresumably what is happening is that the pager does not let color from\nthe previous line impact to the next line.\n\nUnfortunately I don't know if there's an easy workaround. What you\nreally want is to apply the \"+\" magic to a whole section of the string.\nYou can do that with git-for-each-ref's format, like:\n\n  %(if)%D%(then)%n%C(red)%D%(end)\n\nbut the two formats are not (yet) unified. There's interest in doing\nthat, and an Outreachy intern worked on it over the winter, but there's\nstill a long way to go.\n\n-Peff\n"}]}