Branch Coverage

deps/libgit2/src/libgit2/pathspec.c
Criterion Covered Total %
branch 149 300 49.6


line true false branch
26 260 0 if (!pathspec || !pathspec->count ||
31 151 26 for (scan = prefix.ptr; *scan; ++scan) {
32 10 141 if (git__iswildcard(*scan) &&
9 1 if (git__iswildcard(*scan) &&
33 0 9 (scan == prefix.ptr || (*(scan - 1) != '\\')))
38 4 32 if (prefix.size <= 0) {
53 0 316 if (pathspec == NULL)
56 74 242 for (i = 0; i < pathspec->count; ++i) {
59 74 0 if (str && str[0])
74 0 if (str && str[0])
74 242 74 if (git_pathspec_is_empty(strspec))
77 0 74 if (git_vector_init(vspec, strspec->count, NULL) < 0)
80 84 74 for (i = 0; i < strspec->count; ++i) {
84 0 84 if (!match)
90 0 84 if (ret == GIT_ENOTFOUND) {
93 0 84 } else if (ret < 0) {
98 0 84 if (git_vector_insert(vspec, match) < 0)
122 0 40 if (disable_fnmatch)
124 3 37 else if (casefold)
129 3 37 if (casefold) {
145 57 0 if (result == WM_NOMATCH)
148 57 0 if (ctxt->wildmatch_flags >= 0 && result == WM_NOMATCH)
40 17 if (ctxt->wildmatch_flags >= 0 && result == WM_NOMATCH)
152 19 38 if (result == WM_NOMATCH &&
9 10 if (result == WM_NOMATCH &&
153 3 6 (match->flags & GIT_ATTR_FNMATCH_HASWILD) == 0 &&
154 1 2 ctxt->strncomp(path, match->pattern, match->length) == 0 &&
161 18 39 if (result == WM_NOMATCH &&
0 18 if (result == WM_NOMATCH &&
162 0 0 (match->flags & GIT_ATTR_FNMATCH_NEGATIVE) != 0 &&
163 0 0 *path == '!' &&
164 0 0 ctxt->strncomp(path + 1, match->pattern, match->length) == 0 &&
165 0 0 (!path[match->length + 1] || path[match->length + 1] == '/'))
168 37 20 if (result == 0)
184 55 13 git_vector_foreach(vspec, i, match) {
185 55 0 if (path0 && (result = pathspec_match_one(match, ctxt, path0)) >= 0)
37 18 if (path0 && (result = pathspec_match_one(match, ctxt, path0)) >= 0)
187 0 18 if (path1 && (result = pathspec_match_one(match, ctxt, path1)) >= 0)
0 0 if (path1 && (result = pathspec_match_one(match, ctxt, path1)) >= 0)
208 651 65 if (matched_pathspec)
210 0 716 if (matched_at)
213 716 0 if (!vspec || !vspec->length)
687 29 if (!vspec || !vspec->length)
219 19 10 if (result >= 0) {
220 18 1 if (matched_pathspec) {
225 0 19 if (matched_at)
241 20 0 if ((error = git_pool_init(&ps->pool, 1)) < 0 ||
0 20 if ((error = git_pool_init(&ps->pool, 1)) < 0 ||
260 0 7 GIT_ERROR_CHECK_ALLOC(ps);
262 0 7 if ((error = git_pathspec__init(ps, pathspec)) < 0) {
280 0 18 if (!ps)
282 7 11 GIT_REFCOUNT_DEC(ps, pathspec_free);
7 0 GIT_REFCOUNT_DEC(ps, pathspec_free);
291 0 0 GIT_ASSERT_ARG(ps);
292 0 0 GIT_ASSERT_ARG(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)
2 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 ||
8 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 GIT_ASSERT_ARG(repo);
533 6 0 if (!(error = git_iterator_for_workdir(&iter, repo, NULL, NULL, &iter_opts))) {
551 0 1 GIT_ASSERT_ARG(index);
555 1 0 if (!(error = git_iterator_for_index(&iter, git_index_owner(index), index, &iter_opts))) {
573 0 4 GIT_ASSERT_ARG(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 GIT_ASSERT_ARG(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;