git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Allan Caffee <allan.caffee@gmail.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [RFC] Colorization of log --graph
Date: Thu, 19 Mar 2009 12:59:23 -0400	[thread overview]
Message-ID: <b2e43f8f0903190959if539048r19e972899bd2132d@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.1.00.0903181228420.10279@pacific.mpi-cbg.de>

Hello and thanks for the speedy reply!

On Wed, Mar 18, 2009 at 7:44 AM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
> Hi,
>
> On Wed, 18 Mar 2009, Allan Caffee wrote:
>
> > I know that _some_ people arn't particularly fond of colors, but I was
> > wondering how difficult it would be to colorize the edges on the --graph
> > drawn by the log command?  It can be a little tricky trying to follow
> > them with a relatively complex history.  I was thinking something like
> > gitk already does.
>
> That's a good idea!  (And it is mentioned as a TODO in graph.c...)

That's me, always thinking outside the box.  ;-)

> > Is anybody else interested in seeing this?
>
> Count me in.  Are you interested in implementing this?

I'll give it a go.  Been a while since I've done anything of substance
in pure C so it should be a nice refresher.  :)

> If so:
>
> - you need to #include "color.h" in graph.c
>
> - you need to insert a color identifier into struct column (there is an
>  XXX comment at the correct location)

By color identifier I assume you mean the ANSI escape sequence, right?
I didn't see a type for representing colors in color.{c,h} other than
the int it seems to use internally.

> - you need to find a way to determine colors for the branches

Okay, so if we were to make this similiar to how gitk works it would involve:
If the previous commit was a merge:
	for (i = 0; i < graph->num_columns; i++)
		graph->columns[i]->color = get_next_column_color();
else
	get_current_column_color();

I was thinking of storing the current color by adding a
default_column_color attribute to git_graph that serves as an index into
column_colors.  column_colors being the array of available colors.

> - you need to put the handling into the function
>  graph_output_pre_commit_line() in graph.c (and probably
>  graph_output_commit_char(), graph_output_post_merge_line(),
>  graph_output_collapsing_line(), graph_padding_line(), and
>  graph_output_padding_line(), too)
>
> - it would make sense IMHO to introduce a new function that takes a
>  pointer to an strbuf, a pointer to a struct column and a char (or maybe
>  a string) that adds the appropriately colorized char (or string) to the
>  strbuf

That makes sense.  Then we can just update the functions you mentioned
above to use this.

> - use the global variable diff_use_color to determine if the output should
>  be colorized at all

The function for adding a column to an strbuf would offer a convenient
place to put the condition.

> - probably you need to make an array of available colors or some such
>  (which might be good to put into color.[ch])

This would be the color_codes array I mentioned but it seems like it
might belong in graph.c.  There's something similiar in diff.c and it
seems like this is more related to graphing then to colors in general.
Although I do think it makes sense to #define some of the more common
ANSI codes there so that they don't have to be duplicated.  grep shows 6
occurrences of '\033[31m', the code for red foreground.

I'll begin working on a patch.  Comments/questions?

~Allan

  reply	other threads:[~2009-03-19 17:01 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-18 10:05 [RFC] Colorization of log --graph Allan Caffee
2009-03-18 11:44 ` Johannes Schindelin
2009-03-19 16:59   ` Allan Caffee [this message]
2009-03-19 17:41     ` Johannes Schindelin
2009-03-19 21:48       ` Nanako Shiraishi
2009-03-20 19:13         ` Allan Caffee
2009-03-20 19:58           ` Jeff King
     [not found]             ` <20090321175726.GA6677@linux.vnet>
2009-03-30 14:13               ` [RFC/PATCH] graph API: Added logic for colored edges Allan Caffee
     [not found]                 ` <cover.1238428115u.git.johannes.schindelin@gmx.de>
2009-03-30 15:49                   ` [PATCH 1/2] graph.c: avoid compile warnings Johannes Schindelin
2009-03-30 15:58                     ` Junio C Hamano
2009-03-30 16:14                       ` Junio C Hamano
2009-03-30 15:49                   ` [PATCH 2/2] --graph: respect --no-color Johannes Schindelin
2009-03-30 16:04                 ` [RFC/PATCH] graph API: Added logic for colored edges Johannes Schindelin
2009-03-31 10:13                 ` Johannes Schindelin
2009-03-31 10:26                   ` Johannes Sixt
2009-03-31 12:09                     ` Johannes Schindelin
2009-03-31 10:21                 ` Johannes Schindelin
2009-03-20 20:13           ` [RFC] Colorization of log --graph Junio C Hamano
2009-03-18 16:52 ` Eric Raible
2009-03-18 17:04   ` Santi Béjar
2009-03-18 17:29     ` Eric Raible
2009-03-19 19:32       ` Markus Heidelberg
2009-03-19 19:52         ` Eric Raible
2009-03-19 20:04           ` Markus Heidelberg

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=b2e43f8f0903190959if539048r19e972899bd2132d@mail.gmail.com \
    --to=allan.caffee@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    /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).