Branch Coverage

deps/libgit2/src/util/sortedcache.c
Criterion Covered Total %
branch 29 92 31.5


line true false branch
21 85 0 pathlen = path ? strlen(path) : 0;
23 0 85 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_sortedcache), pathlen);
0 85 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_sortedcache), pathlen);
24 0 85 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
0 85 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
26 0 85 GIT_ERROR_CHECK_ALLOC(sc);
29 85 0 git_vector_init(&sc->items, 4, item_cmp) < 0 ||
33 0 85 if (git_rwlock_init(&sc->lock)) {
42 85 0 if (pathlen)
70 0 415 if (sc->free_item) {
74 0 0 git_vector_foreach(&sc->items, i, item) {
87 0 82 if (git_sortedcache_wlock(sc) < 0)
102 0 82 if (!sc)
104 82 0 GIT_REFCOUNT_DEC(sc, sortedcache_free);
82 0 GIT_REFCOUNT_DEC(sc, sortedcache_free);
129 31 0 if (!copy_item) {
134 0 31 if ((error = git_sortedcache_new(
140 31 0 if (lock && git_sortedcache_rlock(src) < 0) {
0 31 if (lock && git_sortedcache_rlock(src) < 0) {
145 0 31 git_vector_foreach(&src->items, i, src_item) {
148 0 0 if ((error = git_sortedcache_upsert(&tgt_item, tgt, path)) < 0 ||
0 0 if ((error = git_sortedcache_upsert(&tgt_item, tgt, path)) < 0 ||
153 31 0 if (lock)
155 0 31 if (error)
158 31 0 *out = !error ? tgt : NULL;
168 0 756 if (git_rwlock_wrlock(&sc->lock) < 0) {
187 0 295 if (git_rwlock_rdlock(&sc->lock) < 0) {
209 0 333 if ((error = git_sortedcache_wlock(sc)) < 0)
212 333 0 if ((error = git_futils_filestamp_check(&sc->stamp, sc->path)) <= 0)
215 0 0 if ((fd = git_futils_open_ro(sc->path)) < 0) {
220 0 0 if (p_fstat(fd, &st) < 0) {
227 0 0 if (!git__is_sizet(st.st_size)) {
234 0 0 if (buf)
239 0 0 if (error < 0)
258 333 0 if (wlock && git_sortedcache_wlock(sc) < 0)
0 333 if (wlock && git_sortedcache_wlock(sc) < 0)
263 333 0 if (wlock)
277 0 0 if ((item = git_strmap_get(sc->map, key)) != NULL)
284 0 0 if ((item = git_pool_mallocz(&sc->pool, itemlen)) == NULL) {
297 0 0 if ((error = git_strmap_set(sc->map, item_key, item)) < 0)
300 0 0 if ((error = git_vector_insert(&sc->items, item)) < 0)
304 0 0 if (out)
305 0 0 *out = !error ? item : NULL;
325 0 0 if (!git_vector_is_sorted(&sc->items))
366 0 0 if ((item = git_vector_get(&sc->items, pos)) == NULL) {
375 0 0 if (sc->free_item)