| 613 | } |
| 614 | |
| 615 | static void graph_update_columns(struct git_graph *graph) |
| 616 | { |
| 617 | struct commit_list *parent; |
| 618 | int max_new_columns; |
| 619 | int i, seen_this, is_commit_in_columns; |
| 620 | |
| 621 | /* |
| 622 | * Swap graph->columns with graph->new_columns |
| 623 | * graph->columns contains the state for the previous commit, |
| 624 | * and new_columns now contains the state for our commit. |
| 625 | * |
| 626 | * We'll re-use the old columns array as storage to compute the new |
| 627 | * columns list for the commit after this one. |
| 628 | */ |
| 629 | SWAP(graph->columns, graph->new_columns); |
| 630 | graph->num_columns = graph->num_new_columns; |
| 631 | graph->num_new_columns = 0; |
| 632 | |
| 633 | /* |
| 634 | * Now update new_columns and mapping with the information for the |
| 635 | * commit after this one. |
| 636 | * |
| 637 | * First, make sure we have enough room. At most, there will |
| 638 | * be graph->num_columns + graph->num_parents columns for the next |
| 639 | * commit. |
| 640 | */ |
| 641 | max_new_columns = graph->num_columns + graph->num_parents; |
| 642 | graph_ensure_capacity(graph, max_new_columns); |
| 643 | |
| 644 | /* |
| 645 | * Clear out graph->mapping |
| 646 | */ |
| 647 | graph->mapping_size = 2 * max_new_columns; |
| 648 | for (i = 0; i < graph->mapping_size; i++) |
| 649 | graph->mapping[i] = -1; |
| 650 | |
| 651 | graph->width = 0; |
| 652 | graph->prev_edges_added = graph->edges_added; |
| 653 | graph->edges_added = 0; |
| 654 | |
| 655 | /* |
| 656 | * Populate graph->new_columns and graph->mapping |
| 657 | * |
| 658 | * Some of the parents of this commit may already be in |
| 659 | * graph->columns. If so, graph->new_columns should only contain a |
| 660 | * single entry for each such commit. graph->mapping should |
| 661 | * contain information about where each current branch line is |
| 662 | * supposed to end up after the collapsing is performed. |
| 663 | */ |
| 664 | seen_this = 0; |
| 665 | is_commit_in_columns = 1; |
| 666 | for (i = 0; i <= graph->num_columns; i++) { |
| 667 | struct commit *col_commit; |
| 668 | if (i == graph->num_columns) { |
| 669 | if (seen_this) |
| 670 | break; |
| 671 | is_commit_in_columns = 0; |
| 672 | col_commit = graph->commit; |
no test coverage detected