]> git.ipfire.org Git - thirdparty/git.git/blobdiff - graph.c
test-lib: Remove 3 year old no-op --no-python option
[thirdparty/git.git] / graph.c
diff --git a/graph.c b/graph.c
index 6746d422a98ed010489d4ce74b26a8a4600b183e..ac7c60540645761d3c99fb405a69cb2d06aaddc2 100644 (file)
--- a/graph.c
+++ b/graph.c
@@ -80,12 +80,12 @@ static char column_colors[][COLOR_MAXLEN] = {
        GIT_COLOR_BLUE,
        GIT_COLOR_MAGENTA,
        GIT_COLOR_CYAN,
-       GIT_COLOR_BOLD GIT_COLOR_RED,
-       GIT_COLOR_BOLD GIT_COLOR_GREEN,
-       GIT_COLOR_BOLD GIT_COLOR_YELLOW,
-       GIT_COLOR_BOLD GIT_COLOR_BLUE,
-       GIT_COLOR_BOLD GIT_COLOR_MAGENTA,
-       GIT_COLOR_BOLD GIT_COLOR_CYAN,
+       GIT_COLOR_BOLD_RED,
+       GIT_COLOR_BOLD_GREEN,
+       GIT_COLOR_BOLD_YELLOW,
+       GIT_COLOR_BOLD_BLUE,
+       GIT_COLOR_BOLD_MAGENTA,
+       GIT_COLOR_BOLD_CYAN,
 };
 
 #define COLUMN_COLORS_MAX (ARRAY_SIZE(column_colors))
@@ -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;
 }