Branch Coverage

deps/libgit2/src/pathspec.c
Criterion Covered Total %
branch 146 296 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)
243 0 20 if ((error = git_pathspec__vinit(&ps->pathspec, paths, &ps->pool)) < 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)
334 9 9 if (!git_bitvec_get(used, pos)) {
352 0 2 if (path1 == path0)
355 2 2 for (; start < patterns->length; ++start) {
358 0 2 if (git_bitvec_get(used, start))
361 2 0 if (path0 && pathspec_match_one(pat, ctxt, path0) > 0)
0 2 if (path0 && pathspec_match_one(pat, ctxt, path0) > 0)
363 0 2 else if (path1 && pathspec_match_one(pat, ctxt, path1) > 0)
0 0 else if (path1 && pathspec_match_one(pat, ctxt, path1) > 0)
380 3 2 for (pos = 0; pos < patterns->length; ++pos) {
381 1 2 if (git_bitvec_get(used, pos))
384 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)
389 0 2 if ((*failed = git_pool_strdup(pool, pat->pattern)) == NULL)
407 11 0 bool find_failures = out && (flags & GIT_PATHSPEC_FIND_FAILURES) != 0;
3 8 bool find_failures = out && (flags & GIT_PATHSPEC_FIND_FAILURES) != 0;
408 11 0 bool failures_only = !out || (flags & GIT_PATHSPEC_FAILURES_ONLY) != 0;
0 11 bool failures_only = !out || (flags & GIT_PATHSPEC_FAILURES_ONLY) != 0;
414 0 11 if (git_bitvec_init(&used_patterns, patterns->length) < 0)
417 11 0 if (out) {
419 0 11 GIT_ERROR_CHECK_ALLOC(m);
422 0 11 if ((error = git_iterator_reset_range(iter, ps->prefix, ps->prefix)) < 0)
425 6 5 if (git_iterator_type(iter) == GIT_ITERATOR_WORKDIR &&
0 6 if (git_iterator_type(iter) == GIT_ITERATOR_WORKDIR &&
434 21 11 while (!(error = git_iterator_advance(&entry, iter))) {
440 3 18 if (result < 0)
444 0 18 if (!result) {
451 0 0 git_iterator_current_is_ignored(iter) &&
460 4 14 if (find_failures && used_ct < patterns->length)
2 2 if (find_failures && used_ct < patterns->length)
465 18 0 if (failures_only || !out) {
0 18 if (failures_only || !out) {
466 0 0 if (used_ct == patterns->length)
472 8 10 if ((file = (char **)git_array_alloc(m->matches)) == NULL ||
10 0 if ((file = (char **)git_array_alloc(m->matches)) == NULL ||
479 11 0 if (error < 0 && error != GIT_ITEROVER)
0 11 if (error < 0 && error != GIT_ITEROVER)
484 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 &&
490 1 10 if ((flags & GIT_PATHSPEC_NO_MATCH_ERROR) != 0 && !found_files) {
1 0 if ((flags & GIT_PATHSPEC_NO_MATCH_ERROR) != 0 && !found_files) {
498 1 10 if (error < 0) {
500 1 0 if (out) *out = NULL;
510 3 8 if ((flags & GIT_PATHSPEC_IGNORE_CASE) != 0)
512 0 8 else if ((flags & GIT_PATHSPEC_USE_CASE) != 0)
528 0 6 assert(repo);
532 6 0 if (!(error = git_iterator_for_workdir(&iter, repo, NULL, NULL, &iter_opts))) {
550 0 1 assert(index);
554 1 0 if (!(error = git_iterator_for_index(&iter, git_index_owner(index), index, &iter_opts))) {
572 0 4 assert(tree);
576 4 0 if (!(error = git_iterator_for_tree(&iter, tree, &iter_opts))) {
594 0 0 bool find_failures = out && (flags & GIT_PATHSPEC_FIND_FAILURES) != 0;
0 0 bool find_failures = out && (flags & GIT_PATHSPEC_FIND_FAILURES) != 0;
595 0 0 bool failures_only = !out || (flags & GIT_PATHSPEC_FAILURES_ONLY) != 0;
0 0 bool failures_only = !out || (flags & GIT_PATHSPEC_FAILURES_ONLY) != 0;
600 0 0 assert(diff);
602 0 0 if (git_bitvec_init(&used_patterns, patterns->length) < 0)
605 0 0 if (out) {
607 0 0 GIT_ERROR_CHECK_ALLOC(m);
614 0 0 git_vector_foreach(&diff->deltas, i, delta) {
620 0 0 if (result < 0)
627 0 0 if (!result)
633 0 0 if (find_failures && used_ct < patterns->length)
0 0 if (find_failures && used_ct < patterns->length)
639 0 0 if (failures_only || !out) {
0 0 if (failures_only || !out) {
640 0 0 if (used_ct == patterns->length)
646 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))) {
655 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 &&
661 0 0 if ((flags & GIT_PATHSPEC_NO_MATCH_ERROR) != 0 && !found_deltas) {
0 0 if ((flags & GIT_PATHSPEC_NO_MATCH_ERROR) != 0 && !found_deltas) {
669 0 0 if (error < 0) {
671 0 0 if (out) *out = NULL;
679 10 0 if (m)
686 15 0 return m ? git_array_size(m->matches) : 0;
692 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 ||
696 12 0 return *((const char **)git_array_get(m->matches, pos));
702 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 ||
706 0 0 return *((const git_diff_delta **)git_array_get(m->matches, pos));
712 4 0 return m ? git_array_size(m->failures) : 0;
718 1 0 char **entry = m ? git_array_get(m->failures, pos) : NULL;
1 0 char **entry = m ? git_array_get(m->failures, pos) : NULL;
720 1 0 return entry ? *entry : NULL;