]> git.ipfire.org Git - thirdparty/git.git/blobdiff - graph.c
graph: smooth appearance of collapsing edges on commit lines
[thirdparty/git.git] / graph.c
diff --git a/graph.c b/graph.c
index 2315f3604d9a220a8d2b22b89b3cb61e28ce08f1..63f8d18baa7d7a27d87a12312e18c94de673dae3 100644 (file)
--- a/graph.c
+++ b/graph.c
@@ -297,10 +297,10 @@ struct git_graph {
         */
        int *mapping;
        /*
-        * A temporary array for computing the next mapping state
-        * while we are outputting a mapping line.  This is stored as part
-        * of the git_graph simply so we don't have to allocate a new
-        * temporary array each time we have to output a collapsing line.
+        * A copy of the contents of the mapping array from the last commit,
+        * which we use to improve the display of columns that are tracking
+        * from right to left through a commit line.  We also use this to
+        * avoid allocating a fresh array when we compute the next mapping.
         */
        int *old_mapping;
        /*
@@ -1015,6 +1015,10 @@ static void graph_output_commit_line(struct git_graph *graph, struct graph_line
                                graph_line_write_column(line, col, '\\');
                        else
                                graph_line_write_column(line, col, '|');
+               } else if (graph->prev_state == GRAPH_COLLAPSING &&
+                          graph->old_mapping[2 * i + 1] == i &&
+                          graph->mapping[2 * i] < i) {
+                       graph_line_write_column(line, col, '/');
                } else {
                        graph_line_write_column(line, col, '|');
                }
@@ -1211,6 +1215,11 @@ static void graph_output_collapsing_line(struct git_graph *graph, struct graph_l
                }
        }
 
+       /*
+        * Copy the current mapping array into old_mapping
+        */
+       COPY_ARRAY(graph->old_mapping, graph->mapping, graph->mapping_size);
+
        /*
         * The new mapping may be 1 smaller than the old mapping
         */