Branch Coverage

deps/libgit2/src/libgit2/odb_loose.c
Criterion Covered Total %
branch 134 330 40.6


line true false branch
84 0 1573 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, be->objects_dirlen, GIT_OID_HEXSZ);
0 1573 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, be->objects_dirlen, GIT_OID_HEXSZ);
85 0 1573 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 3);
0 1573 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 3);
86 0 1573 if (git_str_grow(name, alloclen) < 0)
113 0 0 if (len == 0)
121 0 0 while (c & 0x80) {
122 0 0 if (len <= used)
125 0 0 if (sizeof(size_t) * 8 <= shift)
135 0 0 if (out_len)
158 6417 0 for (i = 0, typename_len = 0; i < data_len; i++, typename_len++) {
159 1128 5289 if (data[i] == ' ')
163 0 1128 if (typename_len == data_len)
169 3755 0 for (i = size_idx, size_len = 0; i < data_len; i++, size_len++) {
170 1128 2627 if (data[i] == '\0')
174 0 1128 if (i == data_len)
177 1128 0 if (git__strntol64(&size, &data[size_idx], size_len, NULL, 10) < 0 ||
1128 0 if (git__strntol64(&size, &data[size_idx], size_len, NULL, 10) < 0 ||
188 0 1128 if (GIT_ADD_SIZET_OVERFLOW(out_len, i, 1))
0 1128 if (GIT_ADD_SIZET_OVERFLOW(out_len, i, 1))
202 0 1128 if (data_len < 2)
206 1128 0 return (data[0] & 0x8F) == 0x08 && !(w % 31);
1128 0 return (data[0] & 0x8F) == 0x08 && !(w % 31);
240 0 0 if ((error = parse_header_packlike(&hdr, &head_len, obj_data, obj_len)) < 0)
243 0 0 if (!git_object_typeisloose(hdr.type) || head_len > obj_len) {
0 0 if (!git_object_typeisloose(hdr.type) || head_len > obj_len) {
255 0 0 if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, hdr.size, 1) ||
0 0 if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, hdr.size, 1) ||
261 0 0 if ((error = git_zstream_inflatebuf(&body, obj_data, obj_len)) < 0)
281 757 0 if ((error = git_zstream_init(&zstream, GIT_ZSTREAM_INFLATE)) < 0 ||
757 0 if ((error = git_zstream_init(&zstream, GIT_ZSTREAM_INFLATE)) < 0 ||
292 757 0 if ((error = git_zstream_get_output(head, &decompressed, &zstream)) < 0 ||
757 0 if ((error = git_zstream_get_output(head, &decompressed, &zstream)) < 0 ||
296 0 757 if (!git_object_typeisloose(hdr.type)) {
306 0 757 if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, hdr.size, 1) ||
0 757 if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, hdr.size, 1) ||
312 0 757 GIT_ASSERT(decompressed >= head_len);
315 742 15 if (body_len)
319 0 757 if ((error = git_zstream_get_output(body + body_len, &decompressed, &zstream)) < 0)
322 0 757 if (!git_zstream_done(&zstream)) {
335 0 757 if (error < 0)
347 0 757 GIT_ASSERT_ARG(out);
348 0 757 GIT_ASSERT_ARG(loc);
350 0 757 if (git_str_oom(loc))
357 0 757 if ((error = git_futils_readbuffer(&obj, loc->ptr)) < 0)
360 0 757 if (!is_zlib_compressed_data((unsigned char *)obj.ptr, obj.size))
377 0 0 if ((error = parse_header_packlike(&hdr, &header_len, data, len)) < 0)
395 371 0 if ((error = git_zstream_init(&zs, GIT_ZSTREAM_INFLATE)) < 0 ||
371 0 if ((error = git_zstream_init(&zs, GIT_ZSTREAM_INFLATE)) < 0 ||
396 371 0 (error = git_zstream_set_input(&zs, data, len)) < 0 ||
397 371 0 (error = git_zstream_get_output_chunk(inflated, &inflated_len, &zs)) < 0 ||
415 0 371 GIT_ASSERT_ARG(out);
416 0 371 GIT_ASSERT_ARG(loc);
418 0 371 if (git_str_oom(loc))
423 0 371 if ((error = fd = git_futils_open_ro(loc->ptr)) < 0)
426 0 371 if ((obj_len = p_read(fd, obj, sizeof(obj))) < 0) {
431 0 371 if (!is_zlib_compressed_data(obj, (size_t)obj_len))
436 371 0 if (!error && !git_object_typeisloose(out->type)) {
0 371 if (!error && !git_object_typeisloose(out->type)) {
443 371 0 if (fd >= 0)
455 1127 0 if (!error && !git_fs_path_exists(object_location->ptr))
3 1124 if (!error && !git_fs_path_exists(object_location->ptr))
465 0 10 if (git_str_len(pathbuf) - sstate->dir_len != GIT_OID_HEXSZ - 2) {
470 10 0 if (git_fs_path_isdir(pathbuf->ptr) == false) {
473 8 2 if (!memcmp(sstate->short_oid + 2,
477 8 0 if (!sstate->found) {
486 0 10 if (sstate->found > 1)
506 0 16 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, dir_len, GIT_OID_HEXSZ);
0 16 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, dir_len, GIT_OID_HEXSZ);
507 0 16 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 3);
0 16 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 3);
508 0 16 if (git_str_grow(object_location, alloc_len) < 0)
521 0 16 if (git_str_put(object_location, (char *)state.short_oid, 3) < 0)
526 7 9 if (git_fs_path_isdir(object_location->ptr) == false)
537 0 9 if (error < 0 && error != GIT_EAMBIGUOUS)
0 0 if (error < 0 && error != GIT_EAMBIGUOUS)
540 1 8 if (!state.found)
544 0 8 if (state.found > 1)
549 0 8 if (error)
553 0 8 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, dir_len, GIT_OID_HEXSZ);
0 8 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, dir_len, GIT_OID_HEXSZ);
554 0 8 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2);
0 8 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2);
557 0 8 if (git_str_grow(object_location, alloc_len) < 0)
590 0 371 GIT_ASSERT_ARG(backend);
591 0 371 GIT_ASSERT_ARG(oid);
596 0 371 if (locate_object(&object_path, (loose_backend *)backend, oid) < 0) {
599 371 0 } else if ((error = read_header_loose(&raw, &object_path)) == 0) {
615 0 752 GIT_ASSERT_ARG(backend);
616 0 752 GIT_ASSERT_ARG(oid);
618 3 749 if (locate_object(&object_path, (loose_backend *)backend, oid) < 0) {
621 749 0 } else if ((error = read_loose(&raw, &object_path)) == 0) {
643 138 0 GIT_ASSERT_ARG(len >= GIT_OID_MINPREFIXLEN && len <= GIT_OID_HEXSZ);
0 138 GIT_ASSERT_ARG(len >= GIT_OID_MINPREFIXLEN && len <= GIT_OID_HEXSZ);
645 122 16 if (len == GIT_OID_HEXSZ) {
648 122 0 if (!error)
654 16 0 GIT_ASSERT_ARG(backend && short_oid);
0 16 GIT_ASSERT_ARG(backend && short_oid);
656 8 8 if ((error = locate_object_short_oid(&object_path, out_oid,
657 8 0 (loose_backend *)backend, short_oid, len)) == 0 &&
676 0 4 GIT_ASSERT_ARG(backend);
677 0 4 GIT_ASSERT_ARG(oid);
692 0 0 GIT_ASSERT_ARG(backend);
693 0 0 GIT_ASSERT_ARG(out);
694 0 0 GIT_ASSERT_ARG(short_id);
695 0 0 GIT_ASSERT_ARG(len >= GIT_OID_MINPREFIXLEN);
714 0 121 if (strlen(ptr) != GIT_OID_HEXSZ+1)
717 0 121 if (ptr[2] != '/') {
722 0 121 if (v < 0)
728 2299 121 for (i = 0; i < 38; i += 2) {
730 0 2299 if (v < 0)
744 0 121 if (filename_to_oid(&oid, path->ptr + state->dir_len) < 0)
756 0 99 if (!git_fs_path_isdir(git_str_cstr(path)))
770 0 1 GIT_ASSERT_ARG(backend);
771 0 1 GIT_ASSERT_ARG(cb);
777 0 1 if (git_str_oom(&buf))
830 177 0 if (backend->fsync_object_files || git_repository__fsync_gitdir)
0 177 if (backend->fsync_object_files || git_repository__fsync_gitdir)
845 0 63 GIT_ASSERT_ARG(_backend);
850 0 63 if ((error = git_odb__format_object_header(&hdrlen,
855 0 63 GIT_ERROR_CHECK_ALLOC(stream);
866 0 63 backend->object_file_mode) < 0 ||
876 0 63 return !stream ? -1 : 0;
894 0 0 if (start_remain && buffer_len) {
0 0 if (start_remain && buffer_len) {
905 0 0 if (buffer_len) {
908 0 0 if ((error = git_zstream_get_output(buffer, &chunk, &stream->zstream)) < 0)
941 0 0 if ((error = parse_header_packlike(hdr, &head_len, data, data_len)) < 0)
944 0 0 if (!git_object_typeisloose(hdr->type)) {
961 0 0 if ((error = git_zstream_set_input(&stream->zstream,
972 0 0 if ((error = git_zstream_get_output(head, &init, &stream->zstream)) < 0 ||
0 0 if ((error = git_zstream_get_output(head, &init, &stream->zstream)) < 0 ||
976 0 0 if (!git_object_typeisloose(hdr->type)) {
981 0 0 if (init > head_len) {
1003 0 0 GIT_ASSERT_ARG(stream_out);
1004 0 0 GIT_ASSERT_ARG(len_out);
1005 0 0 GIT_ASSERT_ARG(type_out);
1006 0 0 GIT_ASSERT_ARG(_backend);
1007 0 0 GIT_ASSERT_ARG(oid);
1014 0 0 if (locate_object(&object_path, backend, oid) < 0) {
1021 0 0 GIT_ERROR_CHECK_ALLOC(stream);
1024 0 0 GIT_ERROR_CHECK_ALLOC(hash_ctx);
1026 0 0 if ((error = git_hash_ctx_init(hash_ctx, GIT_HASH_ALGORITHM_SHA1)) < 0 ||
0 0 if ((error = git_hash_ctx_init(hash_ctx, GIT_HASH_ALGORITHM_SHA1)) < 0 ||
1027 0 0 (error = git_futils_mmap_ro_file(&stream->map, object_path.ptr)) < 0 ||
1032 0 0 if (!is_zlib_compressed_data(stream->map.data, stream->map.len))
1037 0 0 if (error < 0)
1050 0 0 if (error < 0) {
1051 0 0 if (stream) {
1056 0 0 if (hash_ctx) {
1078 0 114 if ((error = git_odb__format_object_header(&header_len,
1094 0 114 object_mkdir(&final_path, backend) < 0 ||
1099 0 114 if (error < 0)
1113 0 289 if (object_file_name(&path, backend, oid) < 0)
1138 0 36 GIT_ASSERT_ARG(backend_out);
1139 0 36 GIT_ASSERT_ARG(objects_dir);
1143 0 36 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(loose_backend), objects_dirlen);
0 36 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(loose_backend), objects_dirlen);
1144 0 36 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 2);
0 36 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 2);
1146 0 36 GIT_ERROR_CHECK_ALLOC(backend);
1151 3 33 if (backend->objects_dir[backend->objects_dirlen - 1] != '/')
1154 35 1 if (compression_level < 0)
1157 36 0 if (dir_mode == 0)
1160 36 0 if (file_mode == 0)