Branch Coverage

deps/libgit2/src/libgit2/commit_graph.c
Criterion Covered Total %
branch 16 398 4.0


line true false branch
62 0 0 if (!p)
74 0 0 if (!p)
78 0 0 if (parentcount && !p->parents.ptr)
0 0 if (parentcount && !p->parents.ptr)
81 0 0 if (git_oid_cpy(&p->sha1, git_commit_id(commit)) < 0)
83 0 0 if (git_oid_cpy(&p->tree_oid, git_commit_tree_id(commit)) < 0)
87 0 0 for (i = 0; i < parentcount; ++i) {
88 0 0 git_oid *parent_id = git_array_alloc(p->parents);
0 0 git_oid *parent_id = git_array_alloc(p->parents);
89 0 0 if (!parent_id)
91 0 0 if (git_oid_cpy(parent_id, git_commit_parent_id(commit, i)) < 0)
116 0 0 if (chunk_oid_fanout->offset == 0)
118 0 0 if (chunk_oid_fanout->length == 0)
120 0 0 if (chunk_oid_fanout->length != 256 * 4)
125 0 0 for (i = 0; i < 256; ++i) {
127 0 0 if (n < nr)
143 0 0 if (chunk_oid_lookup->offset == 0)
145 0 0 if (chunk_oid_lookup->length == 0)
147 0 0 if (chunk_oid_lookup->length != file->num_commits * GIT_OID_RAWSZ)
152 0 0 for (i = 0; i < file->num_commits; ++i, oid += GIT_OID_RAWSZ) {
153 0 0 if (git_oid_raw_cmp(prev_oid, oid) >= 0)
166 0 0 if (chunk_commit_data->offset == 0)
168 0 0 if (chunk_commit_data->length == 0)
170 0 0 if (chunk_commit_data->length != file->num_commits * (GIT_OID_RAWSZ + 16))
183 0 0 if (chunk_extra_edge_list->length == 0)
185 0 0 if (chunk_extra_edge_list->length % 4 != 0)
211 0 0 GIT_ASSERT_ARG(file);
213 0 0 if (size < sizeof(struct git_commit_graph_header) + GIT_OID_RAWSZ)
218 0 0 if (hdr->signature != htonl(COMMIT_GRAPH_SIGNATURE) || hdr->version != COMMIT_GRAPH_VERSION
0 0 if (hdr->signature != htonl(COMMIT_GRAPH_SIGNATURE) || hdr->version != COMMIT_GRAPH_VERSION
219 0 0 || hdr->object_id_version != COMMIT_GRAPH_OBJECT_ID_VERSION) {
222 0 0 if (hdr->chunks == 0)
233 0 0 if (trailer_offset < last_chunk_offset)
237 0 0 if (git_hash_buf(checksum, data, (size_t)trailer_offset, GIT_HASH_ALGORITHM_SHA1) < 0)
239 0 0 if (memcmp(checksum, file->checksum, checksum_size) != 0)
244 0 0 for (i = 0; i < hdr->chunks; ++i, chunk_hdr += 12) {
247 0 0 if (chunk_offset < last_chunk_offset)
249 0 0 if (chunk_offset >= trailer_offset)
251 0 0 if (last_chunk != NULL)
289 0 0 if (error < 0)
292 0 0 if (error < 0)
295 0 0 if (error < 0)
298 0 0 if (error < 0)
309 0 35 GIT_ASSERT_ARG(cgraph_out);
310 0 35 GIT_ASSERT_ARG(objects_dir);
313 0 35 GIT_ERROR_CHECK_ALLOC(cgraph);
316 0 35 if (error < 0)
319 0 35 if (open_file) {
321 0 0 if (error < 0)
349 13 0 if (fd < 0)
352 0 0 if (p_fstat(fd, &st) < 0) {
358 0 0 if (!S_ISREG(st.st_mode) || !git__is_sizet(st.st_size)) {
0 0 if (!S_ISREG(st.st_mode) || !git__is_sizet(st.st_size)) {
366 0 0 GIT_ERROR_CHECK_ALLOC(file);
370 0 0 if (error < 0) {
375 0 0 if ((error = git_commit_graph_file_parse(file, file->graph_map.data, cgraph_size)) < 0) {
386 13 166 if (!cgraph->checked) {
396 13 0 if (error < 0)
401 166 0 if (!cgraph->file)
410 166 8 if (!cgraph->checked)
413 0 8 if (cgraph->file
414 0 0 && git_commit_graph_file_needs_refresh(cgraph->file, git_str_cstr(&cgraph->filename))) {
431 0 0 GIT_ASSERT_ARG(e);
432 0 0 GIT_ASSERT_ARG(file);
434 0 0 if (pos >= file->num_commits) {
451 0 0 if (e->parent_indices[1] & 0x80000000u) {
455 0 0 if (extra_edge_list_pos >= file->num_extra_edge_list) {
463 0 0 while (extra_edge_list_pos < file->num_extra_edge_list
464 0 0 && (ntohl(*(
488 0 0 if (fd < 0)
491 0 0 if (p_fstat(fd, &st) < 0) {
496 0 0 if (!S_ISREG(st.st_mode) || !git__is_sizet(st.st_size)
0 0 if (!S_ISREG(st.st_mode) || !git__is_sizet(st.st_size)
497 0 0 || (size_t)st.st_size != file->graph_map.len) {
504 0 0 if (bytes_read != (ssize_t)checksum_size)
520 0 0 GIT_ASSERT_ARG(e);
521 0 0 GIT_ASSERT_ARG(file);
522 0 0 GIT_ASSERT_ARG(short_oid);
525 0 0 lo = ((short_oid->id[0] == 0x0) ? 0 : ntohl(file->oid_fanout[(int)short_oid->id[0] - 1]));
529 0 0 if (pos >= 0) {
537 0 0 if (pos < (int)file->num_commits) {
540 0 0 if (!git_oid_raw_ncmp(short_oid->id, current, len))
545 0 0 if (found && len != GIT_OID_HEXSZ && pos + 1 < (int)file->num_commits) {
0 0 if (found && len != GIT_OID_HEXSZ && pos + 1 < (int)file->num_commits) {
0 0 if (found && len != GIT_OID_HEXSZ && pos + 1 < (int)file->num_commits) {
549 0 0 if (!git_oid_raw_ncmp(short_oid->id, next, len))
553 0 0 if (!found)
556 0 0 if (found > 1)
569 0 0 GIT_ASSERT_ARG(parent);
570 0 0 GIT_ASSERT_ARG(file);
572 0 0 if (n >= entry->parent_count) {
577 0 0 if (n == 0 || (n == 1 && entry->parent_count == 2))
0 0 if (n == 0 || (n == 1 && entry->parent_count == 2))
0 0 if (n == 0 || (n == 1 && entry->parent_count == 2))
592 0 0 GIT_ASSERT_ARG(file);
594 0 0 if (file->graph_map.data)
602 1 35 if (!cgraph)
612 35 0 if (!file)
629 0 0 GIT_ERROR_CHECK_ALLOC(w);
631 0 0 if (git_str_sets(&w->objects_info_dir, objects_info_dir) < 0) {
636 0 0 if (git_vector_init(&w->commits, 0, packed_commit__cmp) < 0) {
651 0 0 if (!w)
654 0 0 git_vector_foreach (&w->commits, i, packed_commit)
677 0 0 if (error < 0)
680 0 0 if (header_type != GIT_OBJECT_COMMIT)
684 0 0 if (error < 0)
689 0 0 GIT_ERROR_CHECK_ALLOC(packed_commit);
692 0 0 if (error < 0) {
712 0 0 if (error < 0)
716 0 0 if (error < 0)
720 0 0 if (error < 0)
724 0 0 if (p)
738 0 0 while ((git_revwalk_next(&id, walk)) == 0) {
740 0 0 if (error < 0)
745 0 0 GIT_ERROR_CHECK_ALLOC(packed_commit);
748 0 0 if (error < 0) {
776 0 0 if (error < 0)
778 0 0 git_vector_foreach (commits, i, child_packed_commit) {
782 0 0 if (error < 0)
786 0 0 git_vector_foreach (commits, i, child_packed_commit) {
793 0 0 if (git_array_size(child_packed_commit->parents)
794 0 0 && !child_packed_commit->parent_indices.ptr) {
798 0 0 git_array_foreach (child_packed_commit->parents, parent_i, parent_id) {
0 0 git_array_foreach (child_packed_commit->parents, parent_i, parent_id) {
800 0 0 if (!parent_packed_commit) {
807 0 0 parent_idx_ptr = git_array_alloc(child_packed_commit->parent_indices);
0 0 parent_idx_ptr = git_array_alloc(child_packed_commit->parent_indices);
808 0 0 if (!parent_idx_ptr) {
821 0 0 if (!index_stack.ptr) {
828 0 0 if (!commit_states) {
837 0 0 git_vector_foreach (commits, i, child_packed_commit)
838 0 0 *(size_t *)git_array_alloc(index_stack) = i;
0 0 *(size_t *)git_array_alloc(index_stack) = i;
840 0 0 while (git_array_size(index_stack)) {
841 0 0 size_t *index_ptr = git_array_pop(index_stack);
845 0 0 if (commit_states[i] == GENERATION_NUMBER_COMMIT_STATE_VISITED) {
849 0 0 if (commit_states[i] == GENERATION_NUMBER_COMMIT_STATE_EXPANDED) {
852 0 0 git_array_foreach (child_packed_commit->parent_indices, j, parent_idx) {
0 0 git_array_foreach (child_packed_commit->parent_indices, j, parent_idx) {
854 0 0 if (child_packed_commit->generation < parent->generation)
857 0 0 if (child_packed_commit->generation
870 0 0 if (git_array_size(child_packed_commit->parent_indices) == 0) {
885 0 0 *(size_t *)git_array_alloc(index_stack) = i;
0 0 *(size_t *)git_array_alloc(index_stack) = i;
886 0 0 git_array_foreach (child_packed_commit->parent_indices, j, parent_idx) {
0 0 git_array_foreach (child_packed_commit->parent_indices, j, parent_idx) {
887 0 0 if (commit_states[*parent_idx]
894 0 0 *(size_t *)git_array_alloc(index_stack) = *parent_idx;
0 0 *(size_t *)git_array_alloc(index_stack) = *parent_idx;
914 0 0 if (error < 0)
918 0 0 if (error < 0)
932 0 0 if (error < 0)
955 0 0 if (error < 0)
997 0 0 if (error < 0)
1006 0 0 if (error < 0)
1011 0 0 for (i = 0; i < 256; i++) {
1012 0 0 while (oid_fanout_count < git_vector_length(&w->commits) &&
0 0 while (oid_fanout_count < git_vector_length(&w->commits) &&
1013 0 0 (packed_commit = (struct packed_commit *)git_vector_get(&w->commits, oid_fanout_count)) &&
1020 0 0 git_vector_foreach (&w->commits, i, packed_commit) {
1025 0 0 if (error < 0)
1031 0 0 git_vector_foreach (&w->commits, i, packed_commit) {
1042 0 0 if (error < 0)
1045 0 0 if (parentcount == 0) {
1048 0 0 packed_index = git_array_get(packed_commit->parent_indices, 0);
1052 0 0 if (error < 0)
1055 0 0 if (parentcount < 2) {
1057 0 0 } else if (parentcount == 2) {
1058 0 0 packed_index = git_array_get(packed_commit->parent_indices, 1);
1064 0 0 if (error < 0)
1067 0 0 if (parentcount > 2) {
1069 0 0 for (parent_i = 1; parent_i < parentcount; ++parent_i) {
1070 0 0 packed_index = git_array_get(
1072 0 0 word = htonl((uint32_t)(*packed_index | (parent_i + 1 == parentcount ? 0x80000000u : 0)));
1077 0 0 if (error < 0)
1085 0 0 if (generation > GIT_COMMIT_GRAPH_GENERATION_NUMBER_MAX)
1089 0 0 if (error < 0)
1093 0 0 if (error < 0)
1099 0 0 if (git_str_len(&extra_edge_list) > 0)
1102 0 0 if (error < 0)
1108 0 0 if (error < 0)
1112 0 0 if (error < 0)
1116 0 0 if (error < 0)
1119 0 0 if (git_str_len(&extra_edge_list) > 0) {
1122 0 0 if (error < 0)
1127 0 0 if (error < 0)
1132 0 0 if (error < 0)
1135 0 0 if (error < 0)
1138 0 0 if (error < 0)
1141 0 0 if (error < 0)
1146 0 0 if (error < 0)
1149 0 0 if (error < 0)
1170 0 0 GIT_INIT_STRUCTURE_FROM_TEMPLATE(
1192 0 0 if (error < 0)
1195 0 0 if (git_repository__fsync_gitdir)
1199 0 0 if (error < 0)
1203 0 0 if (error < 0) {
1216 0 0 GIT_BUF_WRAP_PRIVATE(cgraph, git_commit_graph__writer_dump, w, opts);
0 0 GIT_BUF_WRAP_PRIVATE(cgraph, git_commit_graph__writer_dump, w, opts);