From: Johan Herland <johan@herland.net>
To: Dan McGee <dpmcgee@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] Share color list between graph and show-branch
Date: Tue, 05 Apr 2011 09:29:16 +0200 [thread overview]
Message-ID: <201104050929.17135.johan@herland.net> (raw)
In-Reply-To: <BANLkTint1+c0h9DExydWeeafdgawEJPuMw@mail.gmail.com>
On Tuesday 05 April 2011, Dan McGee wrote:
> On another note, we also have this whole crazy "- 1" bit and the RESET
> element at the end, and yet I see nowhere that slot is actually used.
> It looks like this was introduced by commit 1e3d4119d21df28.
Read that commit again. You'll see that in graph.c:strbuf_write_column() it
replaces
strbuf_addstr(sb, GIT_COLOR_RESET);
with
strbuf_addstr(sb, column_get_color_code(column_colors_max));
which resolves to the same thing. The reason for that extra indirection is
to enable replacing the column_colors_ansi array with a different color
array, to do graph coloring in non-ANSI contexts. Specifically, it was done
to enable HTML/CSS coloring of graphs in CGit:
http://hjemli.net/git/cgit/commit/?id=268b34af23cdcac87aed3300bfe6154cbc65753e
It should be obvious that if we replace the ANSI coloring scheme with some
other coloring scheme, we also need to change the RESET entry (resetting a
HTML "color" with the ANSI reset code is nonsense). Therefore I opted to
move the RESET code into the column_colors array, and make column_colors_max
indicate both (a) the length of the column_colors array, and (b) the index
of the RESET code in that same array. That's why we need the crazy "- 1" bit
when defining COLUMN_COLORS_ANSI_MAX.
BTW, this is documented graph.h:graph_set_column_colors() from the same
1e3d4119d21df28 commit.
...Johan
--
Johan Herland, <johan@herland.net>
www.herland.net
prev parent reply other threads:[~2011-04-05 7:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-31 1:38 [PATCH] Share color list between graph and show-branch Dan McGee
2011-04-03 19:12 ` Junio C Hamano
2011-04-05 0:32 ` Dan McGee
2011-04-05 5:40 ` Dan McGee
2011-04-05 7:29 ` Johan Herland [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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201104050929.17135.johan@herland.net \
--to=johan@herland.net \
--cc=dpmcgee@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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.
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).