MCPcopy Create free account
hub / github.com/git/git / graph_output_collapsing_line

Function graph_output_collapsing_line

graph.c:1276–1437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1274}
1275
1276static void graph_output_collapsing_line(struct git_graph *graph, struct graph_line *line)
1277{
1278 int i;
1279 short used_horizontal = 0;
1280 int horizontal_edge = -1;
1281 int horizontal_edge_target = -1;
1282 int truncated = 0;
1283
1284 /*
1285 * Swap the mapping and old_mapping arrays
1286 */
1287 SWAP(graph->mapping, graph->old_mapping);
1288
1289 /*
1290 * Clear out the mapping array
1291 */
1292 for (i = 0; i < graph->mapping_size; i++)
1293 graph->mapping[i] = -1;
1294
1295 for (i = 0; i < graph->mapping_size; i++) {
1296 int target = graph->old_mapping[i];
1297 if (target < 0)
1298 continue;
1299
1300 /*
1301 * Since update_columns() always inserts the leftmost
1302 * column first, each branch's target location should
1303 * always be either its current location or to the left of
1304 * its current location.
1305 *
1306 * We never have to move branches to the right. This makes
1307 * the graph much more legible, since whenever branches
1308 * cross, only one is moving directions.
1309 */
1310 assert(target * 2 <= i);
1311
1312 if (target * 2 == i) {
1313 /*
1314 * This column is already in the
1315 * correct place
1316 */
1317 assert(graph->mapping[i] == -1);
1318 graph->mapping[i] = target;
1319 } else if (graph->mapping[i - 1] < 0) {
1320 /*
1321 * Nothing is to the left.
1322 * Move to the left by one
1323 */
1324 graph->mapping[i - 1] = target;
1325 /*
1326 * If there isn't already an edge moving horizontally
1327 * select this one.
1328 */
1329 if (horizontal_edge == -1) {
1330 int j;
1331 horizontal_edge = i;
1332 horizontal_edge_target = target;
1333 /*

Callers 1

graph_next_lineFunction · 0.85

Calls 6

graph_needs_truncationFunction · 0.85
graph_line_addstrFunction · 0.85
graph_line_addchFunction · 0.85
graph_line_write_columnFunction · 0.85
graph_is_mapping_correctFunction · 0.85
graph_update_stateFunction · 0.85

Tested by

no test coverage detected