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

Function init_topo_walk

revision.c:3838–3911  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3836}
3837
3838static void init_topo_walk(struct rev_info *revs)
3839{
3840 struct topo_walk_info *info;
3841 struct commit_list *list;
3842 if (revs->topo_walk_info)
3843 reset_topo_walk(revs);
3844
3845 revs->topo_walk_info = xmalloc(sizeof(struct topo_walk_info));
3846 info = revs->topo_walk_info;
3847 memset(info, 0, sizeof(struct topo_walk_info));
3848
3849 init_indegree_slab(&info->indegree);
3850 memset(&info->explore_queue, 0, sizeof(info->explore_queue));
3851 memset(&info->indegree_queue, 0, sizeof(info->indegree_queue));
3852 memset(&info->topo_queue, 0, sizeof(info->topo_queue));
3853
3854 switch (revs->sort_order) {
3855 default: /* REV_SORT_IN_GRAPH_ORDER */
3856 info->topo_queue.compare = NULL;
3857 break;
3858 case REV_SORT_BY_COMMIT_DATE:
3859 info->topo_queue.compare = compare_commits_by_commit_date;
3860 break;
3861 case REV_SORT_BY_AUTHOR_DATE:
3862 init_author_date_slab(&info->author_date);
3863 info->topo_queue.compare = compare_commits_by_author_date;
3864 info->topo_queue.cb_data = &info->author_date;
3865 break;
3866 }
3867
3868 info->explore_queue.compare = compare_commits_by_gen_then_commit_date;
3869 info->indegree_queue.compare = compare_commits_by_gen_then_commit_date;
3870
3871 info->min_generation = GENERATION_NUMBER_INFINITY;
3872 for (list = revs->commits; list; list = list->next) {
3873 struct commit *c = list->item;
3874 timestamp_t generation;
3875
3876 if (repo_parse_commit_gently(revs->repo, c, 1))
3877 continue;
3878
3879 test_flag_and_insert(&info->explore_queue, c, TOPO_WALK_EXPLORED);
3880 test_flag_and_insert(&info->indegree_queue, c, TOPO_WALK_INDEGREE);
3881
3882 generation = commit_graph_generation(c);
3883 if (generation < info->min_generation)
3884 info->min_generation = generation;
3885
3886 *(indegree_slab_at(&info->indegree, c)) = 1;
3887
3888 if (revs->sort_order == REV_SORT_BY_AUTHOR_DATE)
3889 record_author_date(&info->author_date, c);
3890 }
3891 compute_indegrees_to_depth(revs, info->min_generation);
3892
3893 for (list = revs->commits; list; list = list->next) {
3894 struct commit *c = list->item;
3895

Callers 1

prepare_revision_walkFunction · 0.85

Calls 10

reset_topo_walkFunction · 0.85
repo_parse_commit_gentlyFunction · 0.85
test_flag_and_insertFunction · 0.85
commit_graph_generationFunction · 0.85
record_author_dateFunction · 0.85
prio_queue_putFunction · 0.85
prio_queue_reverseFunction · 0.85
trace2_is_enabledFunction · 0.85
xmallocFunction · 0.70

Tested by

no test coverage detected