Branch Coverage

deps/libgit2/src/filter.c
Criterion Covered Total %
branch 170 316 53.8


line true false branch
57 4 90 return (pa < pb) ? -1 : (pa > pb) ? 1 : 0;
78 0 176 if (!scan)
81 348 176 while (*scan) {
82 172 348 while (git__isspace(*scan)) scan++;
84 1650 176 for (start = scan, has_eq = 0; *scan && !git__isspace(*scan); ++scan) {
1478 172 for (start = scan, has_eq = 0; *scan && !git__isspace(*scan); ++scan) {
85 0 1478 if (*scan == '=')
89 348 0 if (scan > start) {
91 348 0 if (has_eq || *start == '-' || *start == '+' || *start == '!')
348 0 if (has_eq || *start == '-' || *start == '+' || *start == '!')
262 86 if (has_eq || *start == '-' || *start == '+' || *start == '!')
0 262 if (has_eq || *start == '-' || *start == '+' || *start == '!')
94 0 348 if (has_eq)
109 348 176 for (i = 0; i < fdef->nattrs; ++i) {
115 0 0 for (scan++; *scan != '='; scan++) /* find '=' */;
139 29 0 fdef ? ((const git_filter_def *)fdef)->filter_name : NULL;
140 29 0 return name ? git__strcmp(key, name) : -1;
145 0 0 const void *filter = fdef ? ((const git_filter_def *)fdef)->filter : NULL;
146 0 0 return (key == filter) ? 0 : -1;
157 0 176 if (filter_def_scan_attrs(&attrs, &nattr, &nmatch, filter->attributes) < 0)
160 0 176 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&alloc_len, nattr, 2);
0 176 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&alloc_len, nattr, 2);
161 0 176 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&alloc_len, alloc_len, sizeof(char *));
0 176 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&alloc_len, alloc_len, sizeof(char *));
162 0 176 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, sizeof(git_filter_def));
0 176 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, sizeof(git_filter_def));
165 0 176 GIT_ERROR_CHECK_ALLOC(fdef);
168 0 176 GIT_ERROR_CHECK_ALLOC(fdef->filter_name);
178 0 176 if (git_vector_insert(&filter_registry.filters, fdef) < 0) {
197 0 86 if ((error = git_vector_init(&filter_registry.filters, 2,
203 86 0 GIT_FILTER_CRLF, crlf, GIT_FILTER_CRLF_PRIORITY) < 0 ||
204 0 86 (ident = git_ident_filter_new()) == NULL ||
212 0 86 if (error) {
228 0 0 git_vector_foreach(&filter_registry.filters, pos, fdef) {
229 0 0 if (fdef->filter && fdef->filter->shutdown) {
0 0 if (fdef->filter && fdef->filter->shutdown) {
257 5 3 if (!filter_registry_find(pos, name))
269 4 0 assert(name && filter);
0 4 assert(name && filter);
276 0 4 if (!filter_registry_find(NULL, name)) {
296 0 4 assert(name);
299 4 0 if (!strcmp(GIT_FILTER_CRLF, name) || !strcmp(GIT_FILTER_IDENT, name)) {
0 4 if (!strcmp(GIT_FILTER_CRLF, name) || !strcmp(GIT_FILTER_IDENT, name)) {
309 0 4 if ((fdef = filter_registry_lookup(&pos, name)) == NULL) {
317 4 0 if (fdef->initialized && fdef->filter && fdef->filter->shutdown) {
4 0 if (fdef->initialized && fdef->filter && fdef->filter->shutdown) {
2 2 if (fdef->initialized && fdef->filter && fdef->filter->shutdown) {
335 18 0 if (!fdef->initialized && fdef->filter && fdef->filter->initialize) {
18 0 if (!fdef->initialized && fdef->filter && fdef->filter->initialize) {
1 17 if (!fdef->initialized && fdef->filter && fdef->filter->initialize) {
336 0 1 if ((error = fdef->filter->initialize(fdef->filter)) < 0)
355 1 3 if ((fdef = filter_registry_lookup(&pos, name)) == NULL ||
0 1 if ((fdef = filter_registry_lookup(&pos, name)) == NULL ||
356 0 0 (!fdef->initialized && filter_initialize(fdef) < 0))
388 0 1 return git_oid_is_zero(&src->oid) ? NULL : &src->oid;
405 59 0 size_t pathlen = src->path ? strlen(src->path) : 0, alloclen;
407 0 59 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_filter_list), pathlen);
0 59 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_filter_list), pathlen);
408 0 59 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
0 59 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
411 0 59 GIT_ERROR_CHECK_ALLOC(fl);
413 59 0 if (src->path)
436 0 461 GIT_ERROR_CHECK_ALLOC(strs);
438 0 461 if ((src->flags & GIT_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
441 0 461 if ((src->flags & GIT_FILTER_ATTRIBUTES_FROM_HEAD) != 0)
448 0 461 if (error == GIT_ENOTFOUND && !fdef->nmatches) {
0 0 if (error == GIT_ENOTFOUND && !fdef->nmatches) {
454 1150 228 for (i = 0; !error && i < fdef->nattrs; ++i) {
917 233 for (i = 0; !error && i < fdef->nattrs; ++i) {
458 689 228 if (!want)
464 228 0 if (want_type != found_type)
466 0 0 else if (want_type == GIT_ATTR_VALUE_STRING &&
0 0 else if (want_type == GIT_ATTR_VALUE_STRING &&
467 0 0 strcmp(want, strs[i]) &&
472 228 233 if (error)
519 31 197 if (blob)
522 461 228 git_vector_foreach(&filter_registry.filters, idx, fdef) {
526 461 0 if (!fdef || !fdef->filter)
0 461 if (!fdef || !fdef->filter)
529 461 0 if (fdef->nattrs > 0) {
533 228 233 if (error == GIT_ENOTFOUND) {
536 0 233 } else if (error < 0)
540 18 215 if (!fdef->initialized && (error = filter_initialize(fdef)) < 0)
0 18 if (!fdef->initialized && (error = filter_initialize(fdef)) < 0)
543 231 2 if (fdef->filter->check)
549 170 63 if (error == GIT_PASSTHROUGH)
551 0 63 else if (error < 0)
554 59 4 if (!fl) {
555 0 59 if ((error = filter_list_new(&fl, &src)) < 0)
561 59 4 fe = git_array_alloc(fl->filters);
4 0 fe = git_array_alloc(fl->filters);
562 0 63 GIT_ERROR_CHECK_ALLOC(fe);
572 0 228 if (error && fl != NULL) {
0 0 if (error && fl != NULL) {
602 122 59 if (!fl)
605 63 59 for (i = 0; i < git_array_size(fl->filters); ++i) {
606 63 0 git_filter_entry *fe = git_array_get(fl->filters, i);
607 60 3 if (fe->filter->cleanup)
621 0 0 assert(name);
623 0 0 if (!fl)
626 0 0 for (i = 0; i < fl->filters.size; i++) {
627 0 0 if (strcmp(fl->filters.ptr[i].filter_name, name) == 0)
642 0 0 assert(fl && filter);
0 0 assert(fl && filter);
649 0 0 if (git_vector_search2(
656 0 0 if (fdef == NULL) {
661 0 0 if (!fdef->initialized && (error = filter_initialize(fdef)) < 0)
0 0 if (!fdef->initialized && (error = filter_initialize(fdef)) < 0)
664 0 0 fe = git_array_alloc(fl->filters);
0 0 fe = git_array_alloc(fl->filters);
665 0 0 GIT_ERROR_CHECK_ALLOC(fe);
674 0 0 return fl ? git_array_size(fl->filters) : 0;
687 0 51 assert(buf_stream);
689 0 51 assert(buf_stream->complete == 0);
697 0 51 assert(buf_stream);
699 0 51 assert(buf_stream->complete == 0);
731 2 30 if (!filters) {
738 0 30 if ((error = git_filter_list_stream_data(filters, src,
742 0 30 assert(writer.complete);
757 2 17 if ((error = git_filter_list_stream_file(
761 0 17 assert(writer.complete);
769 0 33 if (!git__is_sizet(rawsize)) {
788 0 2 if ((error = git_filter_list_stream_blob(
792 0 2 assert(writer.complete);
811 0 65 assert(proxy_stream);
823 0 67 assert(proxy_stream);
832 57 10 if (error == GIT_PASSTHROUGH) {
834 8 2 } else if (error == 0) {
846 65 0 if ((error = proxy_stream->target->write(
856 0 67 assert(proxy_stream);
872 0 67 GIT_ERROR_CHECK_ALLOC(proxy_stream);
881 53 14 proxy_stream->output = temp_buf ? temp_buf : &proxy_stream->temp_buf;
883 14 53 if (temp_buf)
902 19 63 if (!filters) {
908 67 63 for (i = 0; i < git_array_size(filters->filters); ++i) {
910 17 50 git_array_size(filters->filters) - 1 - i : i;
911 67 0 git_filter_entry *fe = git_array_get(filters->filters, filter_idx);
914 67 0 assert(fe->filter->stream || fe->filter->apply);
0 67 assert(fe->filter->stream || fe->filter->apply);
919 0 67 if (fe->filter->stream)
928 0 67 if (error < 0)
936 0 63 if (error)
949 67 82 git_vector_foreach(streams, i, stream)
962 2 17 const char *base = repo ? git_repository_workdir(repo) : NULL;
968 19 0 if ((error = stream_list_init(
969 19 0 &stream_start, &filter_streams, filters, target)) < 0 ||
974 0 19 if ((fd = git_futils_open_ro(abspath.ptr)) < 0) {
979 19 19 while ((readlen = p_read(fd, buf, sizeof(buf))) > 0) {
980 0 19 if ((error = stream_start->write(stream_start, buf, readlen)) < 0)
984 0 19 if (readlen < 0)
988 19 0 if (initialized)
991 19 0 if (fd >= 0)
1009 0 63 if ((error = stream_list_init(&stream_start, &filter_streams, filters, target)) < 0)
1013 0 63 if ((error = stream_start->write(
1018 63 0 if (initialized)
1032 0 33 if (buf_from_blob(&in, blob) < 0)
1035 14 19 if (filters)
1043 0 0 GIT_INIT_STRUCTURE_FROM_TEMPLATE(filter, version, git_filter, GIT_FILTER_INIT);