From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Nguyen Thai Ngoc Duy <pclouds@gmail.com>, "Srb\,
Michal" <michal.srb11@imperial.ac.uk>,
"git\@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: FW: Git log --graph doesn't output color when redirected
Date: Sat, 15 Dec 2012 10:30:12 -0800 [thread overview]
Message-ID: <7v7gojtbgr.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20121215101659.GB21577@sigill.intra.peff.net> (Jeff King's message of "Sat, 15 Dec 2012 05:16:59 -0500")
Jeff King <peff@peff.net> writes:
> On Sat, Dec 15, 2012 at 10:23:10AM +0700, Nguyen Thai Ngoc Duy wrote:
>
>> On Thu, Dec 13, 2012 at 8:13 PM, Jeff King <peff@peff.net> wrote:
>> > If you are using --format="%C(red)" or similar placeholders,
>> > they are the odd duck by not respecting the auto-color mode.
>>
>> But they should, shouldn't they? Just asking. I may do it to when I
>> revive nd/pretty-placeholder-with-color-option.
>
> If I were designing --format today, I would certainly say so. The only
> thing holding me back would be backwards compatibility. We could get
> around that by introducing a new placeholder like %c(color) that behaves
> like %C(color), except respects the --color flag.
I think the %c(color) thing is a good way to go if we want to pursue
this.
Another possibility without wasting one more special letter would be
to allow %C(auto,red), perhaps like this (untested):
pretty.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git i/pretty.c w/pretty.c
index dba6828..77cf826 100644
--- i/pretty.c
+++ w/pretty.c
@@ -960,12 +960,19 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
switch (placeholder[0]) {
case 'C':
if (placeholder[1] == '(') {
- const char *end = strchr(placeholder + 2, ')');
+ const char *begin = placeholder + 2;
+ const char *end = strchr(begin, ')');
char color[COLOR_MAXLEN];
+
if (!end)
return 0;
- color_parse_mem(placeholder + 2,
- end - (placeholder + 2),
+ if (!memcmp(begin, "auto,", 5)) {
+ if (!want_color(GIT_COLOR_AUTO))
+ return 0;
+ begin += 5;
+ }
+ color_parse_mem(begin,
+ end - begin,
"--pretty format", color);
strbuf_addstr(sb, color);
return end - placeholder + 1;
next prev parent reply other threads:[~2012-12-15 18:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <72BB37CB88C48F4B925365539F1EE46C182613A9@icexch-m3.ic.ac.uk>
2012-12-12 17:35 ` FW: Git log --graph doesn't output color when redirected Srb, Michal
2012-12-13 13:13 ` Jeff King
2012-12-13 15:34 ` Srb, Michal
2012-12-15 3:23 ` Nguyen Thai Ngoc Duy
2012-12-15 10:16 ` Jeff King
2012-12-15 18:30 ` Junio C Hamano [this message]
2012-12-17 8:40 ` [PATCH] log --format: teach %C(auto,black) to paint it black only on terminals Junio C Hamano
2012-12-17 11:44 ` Nguyen Thai Ngoc Duy
2012-12-17 12:13 ` Jeff King
2012-12-17 19:34 ` Junio C Hamano
2012-12-17 19:49 ` Jeff King
2012-12-17 20:03 ` Junio C Hamano
2012-12-17 22:55 ` Jeff King
2012-12-17 22:55 ` [PATCH 1/2] t6006: clean up whitespace Junio C Hamano
2012-12-17 22:59 ` Jeff King
2012-12-17 22:56 ` Jeff King
2012-12-17 22:56 ` [PATCH 2/2] log --format: teach %C(auto,black) to respect color config Jeff King
2012-12-17 12:40 ` [PATCH] log --format: teach %C(auto,black) to paint it black only on terminals Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7v7gojtbgr.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=michal.srb11@imperial.ac.uk \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).