Re: [PATCH] Add new git-graph command

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

 



On Mon, Mar 31, 2008 at 08:17:28PM +0300, Teemu Likonen wrote:
> Adam Simpkins kirjoitti:
> 
> > Ultimately, it would probably be better to integrate this
> > functionality into git-log, instead of having it as a standalone
> > command.  For example, a new --graph option could be added to cause
> > the graph to be displayed alongside the existing git log output.
> > However, this would require tighter integration between the graphing
> > code and the log_tree.c and pretty.c code, which I'm not all that
> > familiar with.
> 
> I just want to say that I really like your 'git graph'. I would like to 
> see it integrated to 'git log', perhaps as 'git log --pretty=graph' 
> or 'git log --graph'.

Thanks!

I was thinking more about how to add it to 'git log', and it might not
be all that difficult.  Instead of providing the graphing
functionality as a standalone command, it could be wrapped up in the
following API:

  struct graph;
  void graph_update(struct graph *graph, struct commit *commit);
  void graph_next_line(struct graph *graph, struct strbuf *sb);
  bool graph_is_commit_finished(struct graph *graph);

While walking through the commit list, graph_update() should be called
once for each commit.  After graph_update() has been called,
graph_next_line() can then be called to format the next line of the
graph into the strbuf.  It should be called multiple times, until
graph_is_commit_finished() returns true.  Then graph_update() can be
called with the next commit.

If graph_next_line() is called when graph_is_commit_finished()
returns, it would simply format straight lines for each column.  For
example, if there were currently 3 columns, it would format "| | |".
This allows graph_next_line() to be used to vertically pad the graph.

This API would allow the 'git log' code to format each line of the
graph into a strbuf, and print it out in front of each line of normal
log output.  This way, it could work even with something like
"git log --graph --pretty=full".  The graph would be prefixed to the
normal output, and padded vertically for as long as necessary.

I'm just not sure how difficult it will be to change the log-tree.c
code to invoke graph_next_line() before each individual line of
output.  It certainly shouldn't be that difficult just to implement
'git log --pretty=graph', but it may be more complicated if we want to
make the graphing be a boolean option that can be enabled with any
--pretty format.

I might try coding it up next weekend.

-- 
Adam Simpkins
adam@xxxxxxxxxxxxxxxx
--
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]

  Powered by Linux