git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bo Yang <struggleyb.nku@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, trast@student.ethz.ch, peff@peff.net
Subject: [PATCH 5/6 rebase-version] Register a callback for graph output.
Date: Tue, 25 May 2010 17:02:33 +0800	[thread overview]
Message-ID: <1274778154-29976-6-git-send-email-struggleyb.nku@gmail.com> (raw)
In-Reply-To: <1274778154-29976-5-git-send-email-struggleyb.nku@gmail.com>

It will look better if the 'git log --graph' print
the graph pading lines before the diff output just
like what it does for commit message.
And this patch leverage the new diff prefix callback
function to achieve this.

Signed-off-by: Bo Yang <struggleyb.nku@gmail.com>
---
 graph.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/graph.c b/graph.c
index e6bbcaa..ac7c605 100644
--- a/graph.c
+++ b/graph.c
@@ -211,6 +211,18 @@ struct git_graph {
 	unsigned short default_column_color;
 };
 
+static struct strbuf *diff_output_prefix_callback(struct diff_options *opt, void *data)
+{
+	struct git_graph *graph = data;
+	static struct strbuf msgbuf = STRBUF_INIT;
+
+	assert(graph);
+
+	strbuf_reset(&msgbuf);
+	graph_padding_line(graph, &msgbuf);
+	return &msgbuf;
+}
+
 struct git_graph *graph_init(struct rev_info *opt)
 {
 	struct git_graph *graph = xmalloc(sizeof(struct git_graph));
@@ -244,6 +256,13 @@ struct git_graph *graph_init(struct rev_info *opt)
 	graph->mapping = xmalloc(sizeof(int) * 2 * graph->column_capacity);
 	graph->new_mapping = xmalloc(sizeof(int) * 2 * graph->column_capacity);
 
+	/*
+	 * The diff output prefix callback, with this we can make
+	 * all the diff output to align with the graph lines.
+	 */
+	opt->diffopt.output_prefix = diff_output_prefix_callback;
+	opt->diffopt.output_prefix_data = graph;
+
 	return graph;
 }
 
-- 
1.6.0.4

  reply	other threads:[~2010-05-25  9:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-25  9:02 [PATCH 0/6 rebase-version] Make git log --graph looks better with -p and other diff options Bo Yang
2010-05-25  9:02 ` [PATCH 1/6 rebase-version] Add a prefix output callback to diff output Bo Yang
2010-05-25  9:02   ` [PATCH 2/6 rebase-version] Output the graph columns at the end of the commit message Bo Yang
2010-05-25  9:02     ` [PATCH 3/6 rebase-version] diff.c: Output the text graph padding before each diff line Bo Yang
2010-05-25  9:02       ` [PATCH 4/6 rebase-version] Emit a whole line once a time Bo Yang
2010-05-25  9:02         ` Bo Yang [this message]
2010-05-25  9:02           ` [PATCH 6/6 rebase-version] Make --color-words work well with --graph Bo Yang
2010-05-26  5:07       ` [PATCH 3/6 rebase-version] diff.c: Output the text graph padding before each diff line Junio C Hamano
2010-05-25  9:23 ` [PATCH 0/6 rebase-version] Make git log --graph looks better with -p and other diff options Jeff King
2010-05-25  9:31   ` Bo Yang
2010-05-25  9:33     ` Jeff King
2010-05-25  9:39       ` Bo Yang
2010-05-25  9:47         ` Jeff King

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=1274778154-29976-6-git-send-email-struggleyb.nku@gmail.com \
    --to=struggleyb.nku@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=trast@student.ethz.ch \
    /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).