From: Jeff King <peff@peff.net>
To: Oren Held <oren@held.org.il>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Pretty formats: skip color codes if !want_color()
Date: Mon, 17 Dec 2012 18:10:42 -0500 [thread overview]
Message-ID: <20121217231042.GB1809@sigill.intra.peff.net> (raw)
In-Reply-To: <20121217225703.GC25103@orenhe-laptop>
On Tue, Dec 18, 2012 at 12:57:03AM +0200, Oren Held wrote:
> Avoid color escape codes if colors are disabled, just like the
> behavior of other git commands. This solves the case of color escape
> codes in stdout when piping or redirecting, e.g.: $ git log
> --format=%Cred%h > out
You may be interested in this thread from today, which is attacking the
same problem:
http://thread.gmane.org/gmane.comp.version-control.git/211370/focus=211714
Two issues with your patch:
> @@ -956,6 +962,8 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
> struct commit_list *p;
> int h1, h2;
>
> + int colors_enabled = want_color(GIT_COLOR_UNKNOWN);
> +
I think this would want to use the regular diff color variable to be
consistent with other coloring of "git log".
> @@ -967,20 +975,20 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
> color_parse_mem(placeholder + 2,
> end - (placeholder + 2),
> "--pretty format", color);
> - strbuf_addstr(sb, color);
> + conditional_strbuf_addstr(colors_enabled, sb, color);
> return end - placeholder + 1;
> }
This breaks backwards compatibility for callers who expect the coloring
to be unconditional; adding new syntax would solve that.
The patch I linked to above solves both.
-Peff
prev parent reply other threads:[~2012-12-17 23:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-17 22:57 [PATCH] Pretty formats: skip color codes if !want_color() Oren Held
2012-12-17 23:10 ` Jeff King [this message]
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=20121217231042.GB1809@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=oren@held.org.il \
/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).