Branch Coverage

deps/libgit2/src/libgit2/midx.c
Criterion Covered Total %
branch 2 270 0.7


line true false branch
62 0 0 if (chunk->offset == 0)
64 0 0 if (chunk->length == 0)
66 0 0 if ((error = git_vector_init(&idx->packfile_names, packfiles, git__strcmp_cb)) < 0)
68 0 0 for (i = 0; i < packfiles; ++i) {
70 0 0 if (len == 0)
72 0 0 if (len + 1 > chunk_size)
75 0 0 if (i && strcmp(git_vector_get(&idx->packfile_names, i - 1), packfile_name) >= 0)
0 0 if (i && strcmp(git_vector_get(&idx->packfile_names, i - 1), packfile_name) >= 0)
77 0 0 if (strlen(packfile_name) <= strlen(".idx") || git__suffixcmp(packfile_name, ".idx") != 0)
0 0 if (strlen(packfile_name) <= strlen(".idx") || git__suffixcmp(packfile_name, ".idx") != 0)
79 0 0 if (strchr(packfile_name, '/') != NULL || strchr(packfile_name, '\\') != NULL)
0 0 if (strchr(packfile_name, '/') != NULL || strchr(packfile_name, '\\') != NULL)
93 0 0 if (chunk_oid_fanout->offset == 0)
95 0 0 if (chunk_oid_fanout->length == 0)
97 0 0 if (chunk_oid_fanout->length != 256 * 4)
102 0 0 for (i = 0; i < 256; ++i) {
104 0 0 if (n < nr)
120 0 0 if (chunk_oid_lookup->offset == 0)
122 0 0 if (chunk_oid_lookup->length == 0)
124 0 0 if (chunk_oid_lookup->length != idx->num_objects * GIT_OID_RAWSZ)
129 0 0 for (i = 0; i < idx->num_objects; ++i, oid += GIT_OID_RAWSZ) {
130 0 0 if (git_oid_raw_cmp(prev_oid, oid) >= 0)
143 0 0 if (chunk_object_offsets->offset == 0)
145 0 0 if (chunk_object_offsets->length == 0)
147 0 0 if (chunk_object_offsets->length != idx->num_objects * 8)
160 0 0 if (chunk_object_large_offsets->length == 0)
162 0 0 if (chunk_object_large_offsets->length % 8 != 0)
189 0 0 GIT_ASSERT_ARG(idx);
191 0 0 if (size < sizeof(struct git_midx_header) + GIT_OID_RAWSZ)
196 0 0 if (hdr->signature != htonl(MIDX_SIGNATURE) ||
0 0 if (hdr->signature != htonl(MIDX_SIGNATURE) ||
197 0 0 hdr->version != MIDX_VERSION ||
201 0 0 if (hdr->chunks == 0)
215 0 0 if (trailer_offset < last_chunk_offset)
221 0 0 for (i = 0; i < hdr->chunks; ++i, chunk_hdr += 12) {
226 0 0 if (high_offset >= INT32_MAX)
229 0 0 if (chunk_offset < last_chunk_offset)
231 0 0 if (chunk_offset >= trailer_offset)
233 0 0 if (last_chunk != NULL)
271 0 0 if (error < 0)
274 0 0 if (error < 0)
277 0 0 if (error < 0)
280 0 0 if (error < 0)
283 0 0 if (error < 0)
301 213 0 if (fd < 0)
304 0 0 if (p_fstat(fd, &st) < 0) {
310 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)) {
318 0 0 GIT_ERROR_CHECK_ALLOC(idx);
321 0 0 if (error < 0)
326 0 0 if (error < 0) {
331 0 0 if ((error = git_midx_parse(idx, idx->index_map.data, idx_size)) < 0) {
352 0 0 if (fd < 0)
355 0 0 if (p_fstat(fd, &st) < 0) {
361 0 0 !git__is_sizet(st.st_size) ||
371 0 0 if (bytes_read != (ssize_t)checksum_size)
390 0 0 GIT_ASSERT_ARG(idx);
393 0 0 lo = ((short_oid->id[0] == 0x0) ? 0 : ntohl(idx->oid_fanout[(int)short_oid->id[0] - 1]));
397 0 0 if (pos >= 0) {
405 0 0 if (pos < (int)idx->num_objects) {
408 0 0 if (!git_oid_raw_ncmp(short_oid->id, current, len))
413 0 0 if (found && len != GIT_OID_HEXSZ && pos + 1 < (int)idx->num_objects) {
0 0 if (found && len != GIT_OID_HEXSZ && pos + 1 < (int)idx->num_objects) {
0 0 if (found && len != GIT_OID_HEXSZ && pos + 1 < (int)idx->num_objects) {
417 0 0 if (!git_oid_raw_ncmp(short_oid->id, next, len))
421 0 0 if (!found)
423 0 0 if (found > 1)
428 0 0 if (idx->object_large_offsets && offset & 0x80000000) {
0 0 if (idx->object_large_offsets && offset & 0x80000000) {
433 0 0 if (object_large_offsets_pos >= idx->num_object_large_offsets)
442 0 0 if (pack_index >= git_vector_length(&idx->packfile_names))
459 0 0 GIT_ASSERT_ARG(idx);
461 0 0 for (i = 0; i < idx->num_objects; ++i) {
462 0 0 if ((error = git_oid_fromraw(&oid, &idx->oid_lookup[i * GIT_OID_RAWSZ])) < 0)
465 0 0 if ((error = cb(&oid, data)) != 0)
474 0 0 GIT_ASSERT_ARG(idx);
476 0 0 if (idx->index_map.data)
486 37 0 if (!idx)
507 0 0 GIT_ERROR_CHECK_ALLOC(w);
509 0 0 if (git_str_sets(&w->pack_dir, pack_dir) < 0) {
515 0 0 if (git_vector_init(&w->packs, 0, packfile__cmp) < 0) {
530 0 0 if (!w)
533 0 0 git_vector_foreach (&w->packs, i, p)
549 0 0 if (error < 0)
554 0 0 if (error < 0)
558 0 0 if (error < 0) {
577 0 0 git_midx_entry *entry = git_array_alloc(*state->object_entries_array);
0 0 git_midx_entry *entry = git_array_alloc(*state->object_entries_array);
578 0 0 GIT_ERROR_CHECK_ALLOC(entry);
602 0 0 if (error < 0)
606 0 0 if (error < 0)
616 0 0 if (error < 0)
641 0 0 if (error < 0)
683 0 0 if (error < 0)
689 0 0 git_vector_foreach (&w->packs, i, p) {
698 0 0 if (error < 0)
701 0 0 if (error < 0) {
706 0 0 if (path_len <= strlen(".pack") || git__suffixcmp(git_str_cstr(&relative_index), ".pack") != 0) {
0 0 if (path_len <= strlen(".pack") || git__suffixcmp(git_str_cstr(&relative_index), ".pack") != 0) {
720 0 0 if (error < 0)
726 0 0 if (error < 0)
728 0 0 git_array_foreach (object_entries_array, i, entry) {
0 0 git_array_foreach (object_entries_array, i, entry) {
729 0 0 if ((error = git_vector_set(NULL, &object_entries, i, entry)) < 0)
737 0 0 while (git_str_len(&packfile_names) & 3)
742 0 0 for (i = 0; i < 256; i++) {
750 0 0 git_vector_foreach (&object_entries, i, entry) {
752 0 0 if (error < 0)
758 0 0 git_vector_foreach (&object_entries, i, entry) {
763 0 0 if (error < 0)
765 0 0 if (entry->offset >= 0x80000000l) {
767 0 0 if ((error = write_offset(entry->offset, midx_write_buf, &object_large_offsets)) < 0)
774 0 0 if (error < 0)
781 0 0 if (git_str_len(&object_large_offsets) > 0)
784 0 0 if (error < 0)
790 0 0 if (error < 0)
794 0 0 if (error < 0)
798 0 0 if (error < 0)
802 0 0 if (error < 0)
805 0 0 if (git_str_len(&object_large_offsets) > 0) {
807 0 0 if (error < 0)
812 0 0 if (error < 0)
817 0 0 if (error < 0)
820 0 0 if (error < 0)
823 0 0 if (error < 0)
826 0 0 if (error < 0)
829 0 0 if (error < 0)
834 0 0 if (error < 0)
837 0 0 if (error < 0)
866 0 0 if (error < 0)
869 0 0 if (git_repository__fsync_gitdir)
873 0 0 if (error < 0)
877 0 0 if (error < 0) {
892 0 0 if ((error = git_buf_tostr(&str, midx)) < 0 ||
0 0 if ((error = git_buf_tostr(&str, midx)) < 0 ||