| 1437 | } |
| 1438 | |
| 1439 | int graph_next_line(struct git_graph *graph, struct strbuf *sb) |
| 1440 | { |
| 1441 | int shown_commit_line = 0; |
| 1442 | struct graph_line line = { .buf = sb, .width = 0 }; |
| 1443 | |
| 1444 | /* |
| 1445 | * We could conceivable be called with a NULL commit |
| 1446 | * if our caller has a bug, and invokes graph_next_line() |
| 1447 | * immediately after graph_init(), without first calling |
| 1448 | * graph_update(). Return without outputting anything in this |
| 1449 | * case. |
| 1450 | */ |
| 1451 | if (!graph->commit) |
| 1452 | return -1; |
| 1453 | |
| 1454 | switch (graph->state) { |
| 1455 | case GRAPH_PADDING: |
| 1456 | graph_output_padding_line(graph, &line); |
| 1457 | break; |
| 1458 | case GRAPH_SKIP: |
| 1459 | graph_output_skip_line(graph, &line); |
| 1460 | break; |
| 1461 | case GRAPH_PRE_COMMIT: |
| 1462 | graph_output_pre_commit_line(graph, &line); |
| 1463 | break; |
| 1464 | case GRAPH_COMMIT: |
| 1465 | graph_output_commit_line(graph, &line); |
| 1466 | shown_commit_line = 1; |
| 1467 | break; |
| 1468 | case GRAPH_POST_MERGE: |
| 1469 | graph_output_post_merge_line(graph, &line); |
| 1470 | break; |
| 1471 | case GRAPH_COLLAPSING: |
| 1472 | graph_output_collapsing_line(graph, &line); |
| 1473 | break; |
| 1474 | } |
| 1475 | |
| 1476 | graph_pad_horizontally(graph, &line); |
| 1477 | return shown_commit_line; |
| 1478 | } |
| 1479 | |
| 1480 | static void graph_padding_line(struct git_graph *graph, struct strbuf *sb) |
| 1481 | { |
no test coverage detected