Re: [PATCH] Share color list between graph and show-branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
www.herland.net
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]