Branch Coverage

deps/libgit2/src/pathspec.c
Criterion Covered Total %
branch 148 300 49.3


line true false branch
27 260 0 if (!pathspec || !pathspec->count ||
32 151 26 for (scan = prefix.ptr; *scan; ++scan) {
33 10 141 if (git__iswildcard(*scan) &&
9 1 if (git__iswildcard(*scan) &&
34 0 9 (scan == prefix.ptr || (*(scan - 1) != '\\')))
39 4 32 if (prefix.size <= 0) {
54 0 320 if (pathspec == NULL)
57 78 242 for (i = 0; i < pathspec->count; ++i) {
60 78 0 if (str && str[0])
78 0 if (str && str[0])
75 242 78 if (git_pathspec_is_empty(strspec))
78 0 78 if (git_vector_init(vspec, strspec->count, NULL) < 0)
81 88 78 for (i = 0; i < strspec->count; ++i) {
85 0 88 if (!match)
91 0 88 if (ret == GIT_ENOTFOUND) {
94 0 88 } else if (ret < 0) {
99 0 88 if (git_vector_insert(vspec, match) < 0)
123 0 40 if (disable_fnmatch)
125 3 37 else if (casefold)
130 3 37 if (casefold) {
146 57 0 if (result == WM_NOMATCH)
149 57 0 if (ctxt->wildmatch_flags >= 0 && result == WM_NOMATCH)
40 17 if (ctxt->wildmatch_flags >= 0 && result == WM_NOMATCH)
153 19 38 if (result == WM_NOMATCH &&
9 10 if (result == WM_NOMATCH &&
154 3 6 (match->flags & GIT_ATTR_FNMATCH_HASWILD) == 0 &&
155 1 2 ctxt->strncomp(path, match->pattern, match->length) == 0 &&
162 18 39 if (result == WM_NOMATCH &&
0 18 if (result == WM_NOMATCH &&
163 0 0 (match->flags & GIT_ATTR_FNMATCH_NEGATIVE) != 0 &&
164 0 0 *path == '!' &&
165 0 0 ctxt->strncomp(path + 1, match->pattern, match->length) == 0 &&
166 0 0 (!path[match->length + 1] || path[match->length + 1] == '/'))
169 37 20 if (result == 0)
185 55 13 git_vector_foreach(vspec, i, match) {
186 55 0 if (path0 && (result = pathspec_match_one(match, ctxt, path0)) >= 0)
37 18 if (path0 && (result = pathspec_match_one(match, ctxt, path0)) >= 0)
188 0 18 if (path1 && (result = pathspec_match_one(match, ctxt, path1)) >= 0)
0 0 if (path1 && (result = pathspec_match_one(match, ctxt, path1)) >= 0)
209 651 65 if (matched_pathspec)
211 0 716 if (matched_at)
214 716 0 if (!vspec || !vspec->length)
687 29 if (!vspec || !vspec->length)
220 19 10 if (result >= 0) {
221 18 1 if (matched_pathspec) {
226 0 19 if (matched_at)
242 20 0 if ((error = git_pool_init(&ps->pool, 1)) < 0 ||
0 20 if ((error = git_pool_init(&ps->pool, 1)) < 0 ||
261 0 7 GIT_ERROR_CHECK_ALLOC(ps);
263 0 7 if ((error = git_pathspec__init(ps, pathspec)) < 0) {
281 0 18 if (!ps)
283 7 11 GIT_REFCOUNT_DEC(ps, pathspec_free);
7 0 GIT_REFCOUNT_DEC(ps, pathspec_free);
292 0 0 assert(ps && path);
0 0 assert(ps && path);
300 0 11 if (!m)
316 0 11 if (!m)
319 0 11 if (git_pool_init(&m->pool, 1) < 0)
335 9 9 if (!git_bitvec_get(used, pos)) {
353 0 2 if (path1 == path0)
356 2 2 for (; start < patterns->length; ++start) {
359 0 2 if (git_bitvec_get(used, start))
362 2 0 if (path0 && pathspec_match_one(pat, ctxt, path0) > 0)
0 2 if (path0 && pathspec_match_one(pat, ctxt, path0) > 0)
364 0 2 else if (path1 && pathspec_match_one(pat, ctxt, path1) > 0)
0 0 else if (path1 && pathspec_match_one(pat, ctxt, path1) > 0)
381 3 2 for (pos = 0; pos < patterns->length; ++pos) {
382 1 2 if (git_bitvec_get(used, pos))
385 2 0 if ((failed = git_array_alloc(*failures)) == NULL)
0 0 if ((failed = git_array_alloc(*failures)) == NULL)
0 2 if ((failed = git_array_alloc(*failures)) == NULL)
390 0 2 if ((*failed = git_pool_strdup(pool, pat->pattern)) == NULL)
408 11 0 bool find_failures = out && (flags & GIT_PATHSPEC_FIND_FAILURES) != 0;
3 8 bool find_failures = out && (flags & GIT_PATHSPEC_FIND_FAILURES) != 0;
409 11 0 bool failures_only = !out || (flags & GIT_PATHSPEC_FAILURES_ONLY) != 0;
0 11 bool failures_only = !out || (flags & GIT_PATHSPEC_FAILURES_ONLY) != 0;
415 0 11 if (git_bitvec_init(&used_patterns, patterns->length) < 0)
418 11 0 if (out) {
420 0 11 GIT_ERROR_CHECK_ALLOC(m);
423 0 11 if ((error = git_iterator_reset_range(iter, ps->prefix, ps->prefix)) < 0)
426 6 5 if (git_iterator_type(iter) == GIT_ITERATOR_WORKDIR &&
0 6 if (git_iterator_type(iter) == GIT_ITERATOR_WORKDIR &&
435 21 11 while (!(error = git_iterator_advance(&entry, iter))) {
441 3 18 if (result < 0)
445 0 18 if (!result) {
452 0 0 git_iterator_current_is_ignored(iter) &&
461 4 14 if (find_failures && used_ct < patterns->length)
2 2 if (find_failures && used_ct < patterns->length)
466 18 0 if (failures_only || !out) {
0 18 if (failures_only || !out) {
467 0 0 if (used_ct == patterns->length)
473 8 10 if ((file = (char **)git_array_alloc(m->matches)) == NULL ||
10 0 if ((file = (char **)git_array_alloc(m->matches)) == NULL ||
480 11 0 if (error < 0 && error != GIT_ITEROVER)
0 11 if (error < 0 && error != GIT_ITEROVER)
485 3 8 if (find_failures && used_ct < patterns->length &&
2 1 if (find_failures && used_ct < patterns->length &&
0 2 if (find_failures && used_ct < patterns->length &&
491 1 10 if ((flags & GIT_PATHSPEC_NO_MATCH_ERROR) != 0 && !found_files) {
1 0 if ((flags & GIT_PATHSPEC_NO_MATCH_ERROR) != 0 && !found_files) {
499 1 10 if (error < 0) {
501 1 0 if (out) *out = NULL;
511 3 8 if ((flags & GIT_PATHSPEC_IGNORE_CASE) != 0)
513 0 8 else if ((flags & GIT_PATHSPEC_USE_CASE) != 0)
529 0 6 assert(repo);
533 6 0 if (!(error = git_iterator_for_workdir(&iter, repo, NULL, NULL, &iter_opts))) {
551 0 1 assert(index);
555 1 0 if (!(error = git_iterator_for_index(&iter, git_index_owner(index), index, &iter_opts))) {
573 0 4 assert(tree);
577 4 0 if (!(error = git_iterator_for_tree(&iter, tree, &iter_opts))) {
595 0 0 bool find_failures = out && (flags & GIT_PATHSPEC_FIND_FAILURES) != 0;
0 0 bool find_failures = out && (flags & GIT_PATHSPEC_FIND_FAILURES) != 0;
596 0 0 bool failures_only = !out || (flags & GIT_PATHSPEC_FAILURES_ONLY) != 0;
0 0 bool failures_only = !out || (flags & GIT_PATHSPEC_FAILURES_ONLY) != 0;
601 0 0 assert(diff);
603 0 0 if (git_bitvec_init(&used_patterns, patterns->length) < 0)
606 0 0 if (out) {
608 0 0 GIT_ERROR_CHECK_ALLOC(m);
615 0 0 git_vector_foreach(&diff->deltas, i, delta) {
621 0 0 if (result < 0)
628 0 0 if (!result)
634 0 0 if (find_failures && used_ct < patterns->length)
0 0 if (find_failures && used_ct < patterns->length)
640 0 0 if (failures_only || !out) {
0 0 if (failures_only || !out) {
641 0 0 if (used_ct == patterns->length)
647 0 0 if (!(match = (const git_diff_delta **)git_array_alloc(m->matches))) {
0 0 if (!(match = (const git_diff_delta **)git_array_alloc(m->matches))) {
0 0 if (!(match = (const git_diff_delta **)git_array_alloc(m->matches))) {
656 0 0 if (find_failures && used_ct < patterns->length &&
0 0 if (find_failures && used_ct < patterns->length &&
0 0 if (find_failures && used_ct < patterns->length &&
662 0 0 if ((flags & GIT_PATHSPEC_NO_MATCH_ERROR) != 0 && !found_deltas) {
0 0 if ((flags & GIT_PATHSPEC_NO_MATCH_ERROR) != 0 && !found_deltas) {
670 0 0 if (error < 0) {
672 0 0 if (out) *out = NULL;
680 10 0 if (m)
687 15 0 return m ? git_array_size(m->matches) : 0;
693 12 0 if (!m || m->datatype != PATHSPEC_DATATYPE_STRINGS ||
12 0 if (!m || m->datatype != PATHSPEC_DATATYPE_STRINGS ||
0 12 if (!m || m->datatype != PATHSPEC_DATATYPE_STRINGS ||
697 12 0 return *((const char **)git_array_get(m->matches, pos));
703 0 0 if (!m || m->datatype != PATHSPEC_DATATYPE_DIFF ||
0 0 if (!m || m->datatype != PATHSPEC_DATATYPE_DIFF ||
0 0 if (!m || m->datatype != PATHSPEC_DATATYPE_DIFF ||
707 0 0 return *((const git_diff_delta **)git_array_get(m->matches, pos));
713 4 0 return m ? git_array_size(m->failures) : 0;
719 1 0 char **entry = m ? git_array_get(m->failures, pos) : NULL;
1 0 char **entry = m ? git_array_get(m->failures, pos) : NULL;
721 1 0 return entry ? *entry : NULL;