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

Function graph_update_columns

graph.c:615–727  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

613}
614
615static 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;

Callers 1

graph_updateFunction · 0.85

Calls 5

graph_ensure_capacityFunction · 0.85
first_interesting_parentFunction · 0.85
next_interesting_parentFunction · 0.85

Tested by

no test coverage detected