MCPcopy Index your code
hub / github.com/git/git / fill_commit_in_graph

Function fill_commit_in_graph

commit-graph.c:928–982  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

926}
927
928static int fill_commit_in_graph(struct commit *item,
929 struct commit_graph *g, uint32_t pos)
930{
931 uint32_t edge_value;
932 uint32_t parent_data_pos;
933 struct commit_list **pptr;
934 const unsigned char *commit_data;
935 uint32_t lex_index;
936
937 while (pos < g->num_commits_in_base)
938 g = g->base_graph;
939
940 fill_commit_graph_info(item, g, pos);
941
942 lex_index = pos - g->num_commits_in_base;
943 commit_data = g->chunk_commit_data + st_mult(g->hash_algo->rawsz + 16, lex_index);
944
945 item->object.parsed = 1;
946
947 set_commit_tree(item, NULL);
948
949 pptr = &item->parents;
950
951 edge_value = get_be32(commit_data + g->hash_algo->rawsz);
952 if (edge_value == GRAPH_PARENT_NONE)
953 return 1;
954 pptr = insert_parent_or_die(g, edge_value, pptr);
955
956 edge_value = get_be32(commit_data + g->hash_algo->rawsz + 4);
957 if (edge_value == GRAPH_PARENT_NONE)
958 return 1;
959 if (!(edge_value & GRAPH_EXTRA_EDGES_NEEDED)) {
960 pptr = insert_parent_or_die(g, edge_value, pptr);
961 return 1;
962 }
963
964 parent_data_pos = edge_value & GRAPH_EDGE_LAST_MASK;
965 do {
966 if (g->chunk_extra_edges_size / sizeof(uint32_t) <= parent_data_pos) {
967 error(_("commit-graph extra-edges pointer out of bounds"));
968 commit_list_free(item->parents);
969 item->parents = NULL;
970 item->object.parsed = 0;
971 return 0;
972 }
973 edge_value = get_be32(g->chunk_extra_edges +
974 sizeof(uint32_t) * parent_data_pos);
975 pptr = insert_parent_or_die(g,
976 edge_value & GRAPH_EDGE_LAST_MASK,
977 pptr);
978 parent_data_pos++;
979 } while (!(edge_value & GRAPH_LAST_EDGE));
980
981 return 1;
982}
983
984static int search_commit_pos_in_graph(const struct object_id *id, struct commit_graph *g, uint32_t *pos)
985{

Callers 2

lookup_commit_in_graphFunction · 0.85

Calls 7

fill_commit_graph_infoFunction · 0.85
st_multFunction · 0.85
get_be32Function · 0.85
insert_parent_or_dieFunction · 0.85
errorFunction · 0.85
commit_list_freeFunction · 0.85
set_commit_treeFunction · 0.70

Tested by

no test coverage detected