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 71 0 size_t pathlen = src->path ? strlen(src->path) : 0, alloclen;
407 0 71 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_filter_list), pathlen);
0 71 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_filter_list), pathlen);
408 0 71 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
0 71 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
411 0 71 GIT_ERROR_CHECK_ALLOC(fl);
413 71 0 if (src->path)
436 0 545 GIT_ERROR_CHECK_ALLOC(strs);
438 0 545 if ((src->flags & GIT_FILTER_NO_SYSTEM_ATTRIBUTES) != 0)
441 0 545 if ((src->flags & GIT_FILTER_ATTRIBUTES_FROM_HEAD) != 0)
448 0 545 if (error == GIT_ENOTFOUND && !fdef->nmatches) {
0 0 if (error == GIT_ENOTFOUND && !fdef->nmatches) {
454 1359 269 for (i = 0; !error && i < fdef->nattrs; ++i) {
1083 276 for (i = 0; !error && i < fdef->nattrs; ++i) {
458 814 269 if (!want)
464 269 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 269 276 if (error)
519 31 238 if (blob)
522 545 269 git_vector_foreach(&filter_registry.filters, idx, fdef) {
526 545 0 if (!fdef || !fdef->filter)
0 545 if (!fdef || !fdef->filter)
529 545 0 if (fdef->nattrs > 0) {
533 269 276 if (error == GIT_ENOTFOUND) {
536 0 276 } else if (error < 0)
540 18 258 if (!fdef->initialized && (error = filter_initialize(fdef)) < 0)
0 18 if (!fdef->initialized && (error = filter_initialize(fdef)) < 0)
543 274 2 if (fdef->filter->check)
549 201 75 if (error == GIT_PASSTHROUGH)
551 0 75 else if (error < 0)
554 71 4 if (!fl) {
555 0 71 if ((error = filter_list_new(&fl, &src)) < 0)
561 71 4 fe = git_array_alloc(fl->filters);
4 0 fe = git_array_alloc(fl->filters);
562 0 75 GIT_ERROR_CHECK_ALLOC(fe);
572 0 269 if (error && fl != NULL) {
0 0 if (error && fl != NULL) {
602 151 71 if (!fl)
605 75 71 for (i = 0; i < git_array_size(fl->filters); ++i) {
606 75 0 git_filter_entry *fe = git_array_get(fl->filters, i);
607 72 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 63 assert(buf_stream);
689 0 63 assert(buf_stream->complete == 0);
697 0 63 assert(buf_stream);
699 0 63 assert(buf_stream->complete == 0);
731 2 42 if (!filters) {
738 0 42 if ((error = git_filter_list_stream_data(filters, src,
742 0 42 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 77 assert(proxy_stream);
823 0 79 assert(proxy_stream);
832 69 10 if (error == GIT_PASSTHROUGH) {
834 8 2 } else if (error == 0) {
846 77 0 if ((error = proxy_stream->target->write(
856 0 79 assert(proxy_stream);
872 0 79 GIT_ERROR_CHECK_ALLOC(proxy_stream);
881 65 14 proxy_stream->output = temp_buf ? temp_buf : &proxy_stream->temp_buf;
883 14 65 if (temp_buf)
902 19 75 if (!filters) {
908 79 75 for (i = 0; i < git_array_size(filters->filters); ++i) {
910 17 62 git_array_size(filters->filters) - 1 - i : i;
911 79 0 git_filter_entry *fe = git_array_get(filters->filters, filter_idx);
914 79 0 assert(fe->filter->stream || fe->filter->apply);
0 79 assert(fe->filter->stream || fe->filter->apply);
919 0 79 if (fe->filter->stream)
928 0 79 if (error < 0)
936 0 75 if (error)
949 79 94 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 75 if ((error = stream_list_init(&stream_start, &filter_streams, filters, target)) < 0)
1013 0 75 if ((error = stream_start->write(
1018 75 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);