*/
if (!graph->visual_root_depth && flags.is_next_visual_root)
graph->visual_root_cascade = 1;
+
+ /*
+ * We wrap the cascading at a max of four columns at most, after
+ * that we wrap it back to the initial column.
+ *
+ * This could cause ambiguity in case of the next commit not
+ * being a visual root and be at the initial column after the
+ * first wrap.
+ *
+ * In case of being a non-visual-root the next, stop the
+ * cascading to get the commit indented.
+ */
+ if (!flags.is_next_visual_root &&
+ graph->visual_root_depth &&
+ !(graph->visual_root_depth % 4))
+ graph->visual_root_cascade = 0;
+
graph->visual_root_depth++;
} else {
graph->visual_root_depth = 0;
* Each visual column is 2 characters wide.
* Omit the indentation for the first visual
* root in cascade mode.
+ *
+ * Have a max of 4 columns when cascading, after
+ * that wrap it and repeat.
*/
- int padding = (depth - graph->visual_root_cascade) * 2;
+ int padding = ((depth - graph->visual_root_cascade) % 4) * 2;
graph_line_addchars(line, ' ', padding);
graph->width += padding;
}
EOF
'
+# The cascading wraps after 4 columns and when wraping (column % 4 == 0) if the
+# next is a non visual-root, force indentation to avoid an ambiguous graph
+# (commit 59_A is forcefully indented)
+test_expect_success 'visual root cascading gets wrapped after 4 columns' '
+ create_orphan _58 && test_commit 58_A && test_commit 58_B &&
+ create_orphan _59 && test_commit 59_A &&
+ create_orphan _60 && test_commit 60_A &&
+ create_orphan _61 && test_commit 61_A &&
+ create_orphan _62 && test_commit 62_A &&
+ create_orphan _63 && test_commit 63_A &&
+ create_orphan _64 && test_commit 64_A &&
+ create_orphan _65 && test_commit 65_A &&
+ create_orphan _66 && test_commit 66_A &&
+ create_orphan _67 && test_commit 67_A &&
+ lib_test_check_graph _58 _59 _60 _61 _62 _63 _64 _65 _66 _67 <<-\EOF
+ * 67_A
+ * 66_A
+ * 65_A
+ * 64_A
+ * 63_A
+ * 62_A
+ * 61_A
+ * 60_A
+ * 59_A
+ * 58_B
+ * 58_A
+ EOF
+'
+
test_done