@@ -278,10 +278,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;
/*
@@ -1011,6 +1011,10 @@ static void graph_output_commit_line(struct git_graph *graph, struct strbuf *sb)
strbuf_write_column(sb, col, '\\');
else
strbuf_write_column(sb, col, '|');
+ } else if (graph->prev_state == GRAPH_COLLAPSING &&
+ graph->old_mapping[2 * i + 1] == i &&
+ graph->mapping[2 * i] < i) {
+ strbuf_write_column(sb, col, '/');
} else {
strbuf_write_column(sb, col, '|');
}
@@ -1211,6 +1215,11 @@ static void graph_output_collapsing_line(struct git_graph *graph, struct strbuf
}
}
+ /*
+ * 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
*/
@@ -402,7 +402,7 @@ test_expect_success 'octopus merges' '
| | * three
| * | two
| |/
- * | one
+ * / one
|/
o before-octopus
EOF
@@ -667,7 +667,7 @@ cat > expect <<\EOF
* | | fifth
* | | fourth
|/ /
-* | third
+* / third
|/
* second
* initial
@@ -12,9 +12,9 @@ test_expect_success 'set up merge history' '
| | | * 4
| | * | 3
| | |/
- | * | 2
+ | * / 2
| |/
- * | 1
+ * / 1
|/
* initial
EOF
@@ -25,9 +25,9 @@ test_expect_success 'set up merge history' '
<RED>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 4
<RED>|<RESET> <YELLOW>|<RESET> * <MAGENTA>|<RESET> 3
<RED>|<RESET> <YELLOW>|<RESET> <MAGENTA>|<RESET><MAGENTA>/<RESET>
- <RED>|<RESET> * <MAGENTA>|<RESET> 2
+ <RED>|<RESET> * <MAGENTA>/<RESET> 2
<RED>|<RESET> <MAGENTA>|<RESET><MAGENTA>/<RESET>
- * <MAGENTA>|<RESET> 1
+ * <MAGENTA>/<RESET> 1
<MAGENTA>|<RESET><MAGENTA>/<RESET>
* initial
EOF
@@ -68,9 +68,9 @@ test_expect_success 'log --graph with normal octopus merge, no color' '
| | | * 4
| | * | 3
| | |/
- | * | 2
+ | * / 2
| |/
- * | 1
+ * / 1
|/
* initial
EOF
@@ -86,9 +86,9 @@ test_expect_success 'log --graph with normal octopus merge with colors' '
<RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> * 4
<RED>|<RESET> <GREEN>|<RESET> * <BLUE>|<RESET> 3
<RED>|<RESET> <GREEN>|<RESET> <BLUE>|<RESET><BLUE>/<RESET>
- <RED>|<RESET> * <BLUE>|<RESET> 2
+ <RED>|<RESET> * <BLUE>/<RESET> 2
<RED>|<RESET> <BLUE>|<RESET><BLUE>/<RESET>
- * <BLUE>|<RESET> 1
+ * <BLUE>/<RESET> 1
<BLUE>|<RESET><BLUE>/<RESET>
* initial
EOF
@@ -62,7 +62,7 @@ cat > expect <<\EOF
| * | 1_D
* | | 1_C
|/ /
-* | 1_B
+* / 1_B
|/
* 1_A
EOF
@@ -154,7 +154,7 @@ test_expect_success '--graph --full-history -- bar.txt' '
echo "* | $A4" >> expected &&
echo "|\\ \\ " >> expected &&
echo "| |/ " >> expected &&
- echo "* | $A3" >> expected &&
+ echo "* / $A3" >> expected &&
echo "|/ " >> expected &&
echo "* $A2" >> expected &&
git rev-list --graph --full-history --all -- bar.txt > actual &&
@@ -255,7 +255,7 @@ test_expect_success '--graph --boundary ^C3' '
echo "* | | | $A3" >> expected &&
echo "o | | | $A2" >> expected &&
echo "|/ / / " >> expected &&
- echo "o | | $A1" >> expected &&
+ echo "o / / $A1" >> expected &&
echo " / / " >> expected &&
echo "| o $C3" >> expected &&
echo "|/ " >> expected &&