summaryrefslogtreecommitdiff
path: root/graph.c
diff options
context:
space:
mode:
authorBo Yang <struggleyb.nku@gmail.com>2010-05-26 15:23:56 +0800
committerJunio C Hamano <gitster@pobox.com>2010-05-31 18:02:07 -0700
commitb5a4de9d506030fce1b70a06dc49090a46877c3f (patch)
tree513eb9717de38cfcab8f7c95bc2d08f3a9cbaf4f /graph.c
parent2efcc977646320123c0d461664d25c4c93aaa9ee (diff)
downloadgit-b5a4de9d506030fce1b70a06dc49090a46877c3f.tar.gz
graph.c: register a callback for graph output
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'graph.c')
-rw-r--r--graph.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/graph.c b/graph.c
index e6bbcaa8c4..ac7c605406 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;
}