]> git.ipfire.org Git - thirdparty/git.git/blobdiff - graph.c
Merge branch 'km/submodule-doc-use-sm-path' into maint
[thirdparty/git.git] / graph.c
diff --git a/graph.c b/graph.c
index e3fd0ea5f806a2598800041e97f049b2e5ba9ae3..aaf97069bd0b140da425dbc1a5b9fc7250459f13 100644 (file)
--- a/graph.c
+++ b/graph.c
@@ -34,6 +34,7 @@ static void graph_padding_line(struct git_graph *graph, struct strbuf *sb);
  * handle directly. It is assumed that this is the same file handle as the
  * file specified by the graph diff options. This is necessary so that
  * graph_show_strbuf can be called even with a NULL graph.
+ * If a NULL graph is supplied, the strbuf is printed as-is.
  */
 static void graph_show_strbuf(struct git_graph *graph,
                              FILE *file,
@@ -218,7 +219,7 @@ struct git_graph {
        int merge_layout;
        /*
         * The number of columns added to the graph by the current commit. For
-        * 2-way and octopus merges, this is is usually one less than the
+        * 2-way and octopus merges, this is usually one less than the
         * number of parents:
         *
         *              | | |                   | |    \
@@ -1062,7 +1063,7 @@ static void graph_output_post_merge_line(struct git_graph *graph, struct graph_l
        int i, j;
 
        struct commit_list *first_parent = first_interesting_parent(graph);
-       int seen_parent = 0;
+       struct column *parent_col = NULL;
 
        /*
         * Output the post-merge row
@@ -1116,12 +1117,17 @@ static void graph_output_post_merge_line(struct git_graph *graph, struct graph_l
                        graph_line_addch(line, ' ');
                } else {
                        graph_line_write_column(line, col, '|');
-                       if (graph->merge_layout != 0 || i != graph->commit_index - 1)
-                               graph_line_addch(line, seen_parent ? '_' : ' ');
+                       if (graph->merge_layout != 0 || i != graph->commit_index - 1) {
+                               if (parent_col)
+                                       graph_line_write_column(
+                                               line, parent_col, '_');
+                               else
+                                       graph_line_addch(line, ' ');
+                       }
                }
 
                if (col_commit == first_parent->item)
-                       seen_parent = 1;
+                       parent_col = col;
        }
 
        /*
@@ -1218,13 +1224,9 @@ static void graph_output_collapsing_line(struct git_graph *graph, struct graph_l
                         *
                         * The space just to the left of this
                         * branch should always be empty.
-                        *
-                        * The branch to the left of that space
-                        * should be our eventual target.
                         */
                        assert(graph->mapping[i - 1] > target);
                        assert(graph->mapping[i - 2] < 0);
-                       assert(graph->mapping[i - 3] == target);
                        graph->mapping[i - 2] = target;
                        /*
                         * Mark this branch as the horizontal edge to