Commit 04ba516
committed
graph: flatten edges that fuse with their right neighbor
When a merge commit is printed and its final parent is the same commit
that occupies the column to the right of the merge, this results in a
kink in the displayed edges:
* |
|\ \
| |/
| *
Graphs containing these shapes can be hard to read, as the expansion to
the right followed immediately by collapsing back to the left creates a
lot of zig-zagging edges, especially when many columns are present.
We can improve this by eliminating the zig-zag and having the merge's
final parent edge fuse immediately with its neighbor:
* |
|\|
| *
This reduces the horizontal width for the current commit by 2, and
requires one less row, making the graph display more compact. Taken in
combination with other graph-smoothing enhancements, it greatly
compresses the space needed to display certain histories:
*
|\
| * *
| |\ |\
| | * | *
| | | | |\
| | \ | | *
| *-. \ | * |
| |\ \ \ => |/|\|
|/ / / / | | *
| | | / | * |
| | |/ | |/
| | * * /
| * | |/
| |/ *
* |
|/
*
One of the test cases here cannot be correctly rendered in Git v2.23.0;
it produces this output following commit E:
| | *-. \ 5_E
| | |\ \ \
| |/ / / /
| | | / _
| |_|/
|/| |
The new implementation makes sure that the rightmost edge in this
history is not left dangling as above.
Signed-off-by: James Coglan <[email protected]>1 parent 9b24893 commit 04ba516
File tree
3 files changed
+86
-34
lines changed- t
3 files changed
+86
-34
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
| 560 | + | |
| 561 | + | |
560 | 562 | | |
561 | 563 | | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
562 | 578 | | |
563 | 579 | | |
564 | 580 | | |
| |||
604 | 620 | | |
605 | 621 | | |
606 | 622 | | |
| 623 | + | |
| 624 | + | |
607 | 625 | | |
608 | 626 | | |
609 | 627 | | |
| |||
731 | 749 | | |
732 | 750 | | |
733 | 751 | | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | 752 | | |
738 | 753 | | |
739 | 754 | | |
| |||
1041 | 1056 | | |
1042 | 1057 | | |
1043 | 1058 | | |
1044 | | - | |
| 1059 | + | |
1045 | 1060 | | |
1046 | 1061 | | |
1047 | 1062 | | |
| |||
1073 | 1088 | | |
1074 | 1089 | | |
1075 | 1090 | | |
1076 | | - | |
| 1091 | + | |
1077 | 1092 | | |
1078 | 1093 | | |
1079 | 1094 | | |
1080 | 1095 | | |
1081 | 1096 | | |
1082 | | - | |
1083 | | - | |
1084 | | - | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
1085 | 1101 | | |
| 1102 | + | |
| 1103 | + | |
1086 | 1104 | | |
1087 | 1105 | | |
1088 | 1106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
| 14 | + | |
| 15 | + | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
43 | 42 | | |
44 | 43 | | |
45 | 44 | | |
46 | | - | |
47 | | - | |
48 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
49 | 48 | | |
50 | 49 | | |
51 | 50 | | |
| |||
153 | 152 | | |
154 | 153 | | |
155 | 154 | | |
156 | | - | |
157 | | - | |
158 | | - | |
| 155 | + | |
| 156 | + | |
159 | 157 | | |
160 | 158 | | |
161 | 159 | | |
| |||
216 | 214 | | |
217 | 215 | | |
218 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
219 | 257 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
75 | 74 | | |
76 | 75 | | |
77 | 76 | | |
| |||
97 | 96 | | |
98 | 97 | | |
99 | 98 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
105 | 103 | | |
106 | 104 | | |
107 | 105 | | |
| |||
131 | 129 | | |
132 | 130 | | |
133 | 131 | | |
134 | | - | |
135 | | - | |
136 | | - | |
| 132 | + | |
| 133 | + | |
137 | 134 | | |
138 | 135 | | |
139 | 136 | | |
| |||
151 | 148 | | |
152 | 149 | | |
153 | 150 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
158 | 154 | | |
159 | 155 | | |
160 | 156 | | |
| |||
0 commit comments