Branch Coverage

deps/libgit2/src/libgit2/apply.c
Criterion Covered Total %
branch 0 278 0.0


line true false branch
65 0 0 if (git_pool_init(&out->pool, sizeof(git_diff_line)) < 0)
68 0 0 if (!in_len)
71 0 0 for (start = in; start < in + in_len; start = end) {
74 0 0 if (end == NULL)
77 0 0 else if (end < in + in_len)
81 0 0 GIT_ERROR_CHECK_ALLOC(line);
83 0 0 if (git_vector_insert(&out->lines, line) < 0)
94 0 0 if (image == NULL)
110 0 0 if (git_vector_length(&preimage->lines) + linenum >
117 0 0 for (i = 0; i < git_vector_length(&preimage->lines); i++) {
121 0 0 if (preimage_line->content_len != image_line->content_len ||
0 0 if (preimage_line->content_len != image_line->content_len ||
140 0 0 if (linenum > max)
160 0 0 if (postlen > prelen)
163 0 0 else if (prelen > postlen)
167 0 0 if (error) {
172 0 0 for (i = 0; i < git_vector_length(&postimage->lines); i++) {
196 0 0 if (ctx->opts.hunk_cb) {
199 0 0 if (error) {
200 0 0 if (error > 0) {
210 0 0 for (i = 0; i < hunk->line_count; i++) {
212 0 0 git_diff_line *line = git_array_get(patch->lines, linenum), *prev;
214 0 0 if (!line) {
223 0 0 prev = i ? git_array_get(patch->lines, linenum - 1) : NULL;
0 0 prev = i ? git_array_get(patch->lines, linenum - 1) : NULL;
224 0 0 if (prev && prev->content[prev->content_len - 1] == '\n')
0 0 if (prev && prev->content[prev->content_len - 1] == '\n')
228 0 0 if ((error = git_vector_insert(&preimage.lines, line)) < 0 ||
0 0 if ((error = git_vector_insert(&preimage.lines, line)) < 0 ||
233 0 0 if ((error = git_vector_insert(&preimage.lines, line)) < 0)
237 0 0 if ((error = git_vector_insert(&postimage.lines, line)) < 0)
243 0 0 if (hunk->hunk.new_start) {
252 0 0 if (!find_hunk_linenum(&line_num, image, &preimage, line_num)) {
280 0 0 if ((error = patch_image_init_fromstr(&image, source, source_len)) < 0)
283 0 0 git_array_foreach(patch->hunks, i, hunk) {
0 0 git_array_foreach(patch->hunks, i, hunk) {
284 0 0 if ((error = apply_hunk(&image, patch, hunk, ctx)) < 0)
288 0 0 git_vector_foreach(&image.lines, i, line)
307 0 0 if (binary_file->datalen == 0)
313 0 0 if (!error && inflated.size != binary_file->inflatedlen) {
0 0 if (!error && inflated.size != binary_file->inflatedlen) {
318 0 0 if (error < 0)
321 0 0 if (binary_file->type == GIT_DIFF_BINARY_DELTA) {
332 0 0 else if (binary_file->type == GIT_DIFF_BINARY_LITERAL) {
354 0 0 if (!patch->binary.contains_data) {
359 0 0 if (!patch->binary.old_file.datalen && !patch->binary.new_file.datalen)
0 0 if (!patch->binary.old_file.datalen && !patch->binary.new_file.datalen)
363 0 0 if ((error = apply_binary_delta(out, source, source_len,
368 0 0 if ((error = apply_binary_delta(&reverse, out->ptr, out->size,
373 0 0 if (source_len != reverse.size ||
0 0 if (source_len != reverse.size ||
374 0 0 (source_len && memcmp(source, reverse.ptr, source_len) != 0)) {
380 0 0 if (error < 0)
401 0 0 GIT_ASSERT_ARG(contents_out);
402 0 0 GIT_ASSERT_ARG(filename_out);
403 0 0 GIT_ASSERT_ARG(mode_out);
404 0 0 GIT_ASSERT_ARG(source || !source_len);
0 0 GIT_ASSERT_ARG(source || !source_len);
405 0 0 GIT_ASSERT_ARG(patch);
407 0 0 if (given_opts)
413 0 0 if (patch->delta->status != GIT_DELTA_DELETED) {
417 0 0 mode = newfile->mode ?
421 0 0 if (patch->delta->flags & GIT_DIFF_FLAG_BINARY)
423 0 0 else if (patch->hunks.size)
428 0 0 if (error)
441 0 0 if (error < 0)
469 0 0 if ((error = git_patch_from_diff(&patch, diff, i)) < 0)
474 0 0 if (opts->delta_cb) {
477 0 0 if (error) {
478 0 0 if (error > 0)
489 0 0 if (delta->status != GIT_DELTA_RENAMED &&
0 0 if (delta->status != GIT_DELTA_RENAMED &&
491 0 0 if (git_strmap_exists(removed_paths, delta->old_file.path)) {
504 0 0 if (delta->status != GIT_DELTA_RENAMED) {
505 0 0 if ((error = git_reader_read(&pre_contents, &pre_id, &pre_filemode,
508 0 0 } else if (error == GIT_ENOTFOUND) {
516 0 0 if (!skip_preimage && delta->status != GIT_DELTA_ADDED) {
0 0 if (!skip_preimage && delta->status != GIT_DELTA_ADDED) {
521 0 0 if (error == GIT_ENOTFOUND)
525 0 0 if (error == GIT_READER_MISMATCH)
528 0 0 if (error < 0)
546 0 0 if (preimage) {
549 0 0 pre_entry.mode = delta->old_file.mode ? delta->old_file.mode : pre_filemode;
552 0 0 if ((error = git_index_add(preimage, &pre_entry)) < 0)
557 0 0 if (delta->status != GIT_DELTA_DELETED) {
558 0 0 if ((error = git_apply__patch(&post_contents, &filename, &mode,
559 0 0 pre_contents.ptr, pre_contents.size, patch, opts)) < 0 ||
569 0 0 if ((error = git_index_add(postimage, &post_entry)) < 0)
573 0 0 if (delta->status == GIT_DELTA_RENAMED ||
0 0 if (delta->status == GIT_DELTA_RENAMED ||
577 0 0 if (delta->status == GIT_DELTA_RENAMED ||
0 0 if (delta->status == GIT_DELTA_RENAMED ||
603 0 0 if (git_strmap_new(&removed_paths) < 0)
606 0 0 for (i = 0; i < git_diff_num_deltas(diff); i++) {
607 0 0 if ((error = apply_one(repo, pre_reader, preimage, post_reader, postimage, diff, removed_paths, i, opts)) < 0)
630 0 0 GIT_ASSERT_ARG(out);
631 0 0 GIT_ASSERT_ARG(repo);
632 0 0 GIT_ASSERT_ARG(preimage);
633 0 0 GIT_ASSERT_ARG(diff);
637 0 0 if (given_opts)
640 0 0 if ((error = git_reader_for_tree(&pre_reader, preimage)) < 0)
647 0 0 if ((error = git_index_new(&postimage)) < 0 ||
0 0 if ((error = git_index_new(&postimage)) < 0 ||
648 0 0 (error = git_index_read_tree(postimage, preimage)) < 0 ||
657 0 0 for (i = 0; i < git_diff_num_deltas(diff); i++) {
660 0 0 if (delta->status == GIT_DELTA_DELETED ||
0 0 if (delta->status == GIT_DELTA_DELETED ||
662 0 0 if ((error = git_index_remove(postimage,
668 0 0 if ((error = apply_deltas(repo, pre_reader, NULL, post_reader, postimage, diff, &opts)) < 0)
674 0 0 if (error < 0)
703 0 0 if ((error = git_vector_init(&paths, git_diff_num_deltas(diff), NULL)) < 0)
706 0 0 for (i = 0; i < git_diff_num_deltas(diff); i++) {
709 0 0 if ((error = git_vector_insert(&paths, (void *)delta->old_file.path)) < 0)
712 0 0 if (strcmp(delta->old_file.path, delta->new_file.path) &&
0 0 if (strcmp(delta->old_file.path, delta->new_file.path) &&
721 0 0 if (location == GIT_APPLY_LOCATION_WORKDIR)
752 0 0 if ((error = git_repository_index(&index, repo)) < 0)
756 0 0 for (i = 0; i < git_diff_num_deltas(diff); i++) {
759 0 0 if (delta->status == GIT_DELTA_DELETED ||
0 0 if (delta->status == GIT_DELTA_DELETED ||
761 0 0 if ((error = git_index_remove(index, delta->old_file.path, 0)) < 0)
767 0 0 for (i = 0; i < git_index_entrycount(postimage); i++) {
770 0 0 if ((error = git_index_add(index, entry)) < 0)
781 0 0 GIT_ASSERT_ARG(opts);
783 0 0 GIT_INIT_STRUCTURE_FROM_TEMPLATE(
816 0 0 GIT_ASSERT_ARG(repo);
817 0 0 GIT_ASSERT_ARG(diff);
819 0 0 GIT_ERROR_CHECK_VERSION(
822 0 0 if (given_opts)
844 0 0 if (error < 0)
854 0 0 if ((error = git_index_new(&preimage)) < 0 ||
0 0 if ((error = git_index_new(&preimage)) < 0 ||
855 0 0 (error = git_index_new(&postimage)) < 0 ||
859 0 0 if (!(opts.flags & GIT_APPLY_CHECK))
860 0 0 if ((error = git_repository_index(&index, repo)) < 0 ||
0 0 if ((error = git_repository_index(&index, repo)) < 0 ||
864 0 0 if ((error = apply_deltas(repo, pre_reader, preimage, post_reader, postimage, diff, &opts)) < 0)
867 0 0 if ((opts.flags & GIT_APPLY_CHECK))
884 0 0 if (error < 0)