Git development
 help / color / mirror / Atom feed
From: Adam Simpkins <adam@adamsimpkins.net>
To: Teemu Likonen <tlikonen@iki.fi>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Add new git-graph command
Date: Mon, 31 Mar 2008 11:47:38 -0700	[thread overview]
Message-ID: <20080331184737.GA28412@adamsimpkins.net> (raw)
In-Reply-To: <200803312017.28354.tlikonen@iki.fi>

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@adamsimpkins.net

  reply	other threads:[~2008-03-31 18:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-30 19:58 [PATCH] Add new git-graph command Adam Simpkins
2008-03-30 20:41 ` Jakub Narebski
2008-03-30 22:00   ` Adam Simpkins
2008-03-30 20:44 ` Matthieu Moy
2008-03-30 22:02   ` Adam Simpkins
2008-03-30 22:54 ` Johannes Schindelin
2008-03-30 23:49 ` Junio C Hamano
2008-03-31  7:09   ` Adam Simpkins
2008-03-31 17:17 ` Teemu Likonen
2008-03-31 18:47   ` Adam Simpkins [this message]
2008-04-01  4:05   ` Stephen Sinclair
2008-04-01  4:29     ` Teemu Likonen
2008-04-01  5:02       ` Jeff King
2008-04-01  5:07       ` Teemu Likonen

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=20080331184737.GA28412@adamsimpkins.net \
    --to=adam@adamsimpkins.net \
    --cc=git@vger.kernel.org \
    --cc=tlikonen@iki.fi \
    /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