Branch Coverage

deps/libgit2/src/tree-cache.c
Criterion Covered Total %
branch 66 100 66.0


line true false branch
16 8 55 size_t i, dirlen = end ? (size_t)(end - path) : strlen(path);
18 27 48 for (i = 0; i < tree->children_count; ++i) {
21 15 12 if (child->namelen == dirlen && !memcmp(path, child->name, dirlen))
15 0 if (child->namelen == dirlen && !memcmp(path, child->name, dirlen))
32 169 109 if (tree == NULL)
37 113 0 while (ptr != NULL) {
40 108 5 if (end == NULL) /* End of path */
44 1 4 if (tree == NULL) /* We don't have that tree */
56 40 58 if (tree == NULL) {
64 47 11 if (tree == NULL) /* Can't find it */
67 0 11 if (end == NULL || *end + 1 == '\0')
0 0 if (end == NULL || *end + 1 == '\0')
84 0 23 if ((buffer = memchr(buffer, '\0', buffer_end - buffer)) == NULL)
87 0 23 if (++buffer >= buffer_end)
90 0 23 if (git_tree_cache_new(&tree, name_start, pool) < 0)
94 0 23 if (git__strntol32(&count, buffer, buffer_end - buffer, &buffer, 10) < 0)
99 23 0 if (*buffer != ' ' || ++buffer >= buffer_end)
23 0 if (*buffer != ' ' || ++buffer >= buffer_end)
103 23 0 if (git__strntol32(&count, buffer, buffer_end - buffer, &buffer, 10) < 0 || count < 0)
23 0 if (git__strntol32(&count, buffer, buffer_end - buffer, &buffer, 10) < 0 || count < 0)
108 23 0 if (*buffer != '\n' || ++buffer > buffer_end)
23 0 if (*buffer != '\n' || ++buffer > buffer_end)
112 14 9 if (tree->entry_count >= 0) {
114 0 14 if (buffer + GIT_OID_RAWSZ > buffer_end)
122 12 11 if (tree->children_count > 0) {
125 0 12 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&bufsize, tree->children_count, sizeof(git_tree_cache*));
0 12 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&bufsize, tree->children_count, sizeof(git_tree_cache*));
128 0 12 GIT_ERROR_CHECK_ALLOC(tree->children);
132 12 12 for (i = 0; i < tree->children_count; ++i) {
133 0 12 if (read_tree_internal(&tree->children[i], &buffer, buffer_end, pool) < 0)
151 0 11 if (read_tree_internal(tree, &buffer, buffer_end, pool) < 0)
154 0 11 if (buffer < buffer_end) {
179 246 140 for (i = 0; i < nentries; i++) {
183 80 166 if (git_tree_entry_filemode(entry) == GIT_FILEMODE_TREE)
187 0 140 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&alloc_size, ntrees, sizeof(git_tree_cache *));
0 140 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&alloc_size, ntrees, sizeof(git_tree_cache *));
191 0 140 GIT_ERROR_CHECK_ALLOC(cache->children);
194 246 140 for (i = 0; i < nentries; i++) {
199 166 80 if (git_tree_entry_filemode(entry) != GIT_FILEMODE_TREE) {
204 0 80 if ((error = git_tree_cache_new(&cache->children[j], git_tree_entry_name(entry), pool)) < 0)
207 0 80 if ((error = git_tree_lookup(&subtree, repo, git_tree_entry_id(entry))) < 0)
215 0 80 if (error < 0)
227 0 60 if ((error = git_tree_cache_new(&cache, "", pool)) < 0)
230 0 60 if ((error = read_tree_recursive(cache, tree, pool)) < 0)
244 0 163 GIT_ERROR_CHECK_ALLOC_ADD3(&alloc_size, sizeof(git_tree_cache), name_len, 1);
0 163 GIT_ERROR_CHECK_ALLOC_ADD3(&alloc_size, sizeof(git_tree_cache), name_len, 1);
247 0 163 GIT_ERROR_CHECK_ALLOC(tree);
265 64 92 if (tree->entry_count != -1)
268 64 156 for (i = 0; i < tree->children_count; i++)
276 0 92 return git_buf_oom(out) ? -1 : 0;