Branch Coverage

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


line true false branch
68 0 0 for (start = in; start < in + in_len; start = end) {
71 0 0 if (end == NULL)
74 0 0 else if (end < in + in_len)
78 0 0 GIT_ERROR_CHECK_ALLOC(line);
80 0 0 if (git_vector_insert(&out->lines, line) < 0)
91 0 0 if (image == NULL)
107 0 0 if (git_vector_length(&preimage->lines) + linenum >
114 0 0 for (i = 0; i < git_vector_length(&preimage->lines); i++) {
118 0 0 if (preimage_line->content_len != image_line->content_len ||
0 0 if (preimage_line->content_len != image_line->content_len ||
137 0 0 if (linenum > max)
157 0 0 if (postlen > prelen)
160 0 0 else if (prelen > postlen)
164 0 0 if (error) {
169 0 0 for (i = 0; i < git_vector_length(&postimage->lines); i++) {
193 0 0 if (ctx->opts.hunk_cb) {
196 0 0 if (error) {
197 0 0 if (error > 0) {
207 0 0 for (i = 0; i < hunk->line_count; i++) {
209 0 0 git_diff_line *line = git_array_get(patch->lines, linenum), *prev;
211 0 0 if (!line) {
220 0 0 prev = i ? git_array_get(patch->lines, linenum - 1) : NULL;
0 0 prev = i ? git_array_get(patch->lines, linenum - 1) : NULL;
221 0 0 if (prev && prev->content[prev->content_len - 1] == '\n')
0 0 if (prev && prev->content[prev->content_len - 1] == '\n')
225 0 0 if ((error = git_vector_insert(&preimage.lines, line)) < 0 ||
0 0 if ((error = git_vector_insert(&preimage.lines, line)) < 0 ||
230 0 0 if ((error = git_vector_insert(&preimage.lines, line)) < 0)
234 0 0 if ((error = git_vector_insert(&postimage.lines, line)) < 0)
240 0 0 if (hunk->hunk.new_start) {
249 0 0 if (!find_hunk_linenum(&line_num, image, &preimage, line_num)) {
277 0 0 if ((error = patch_image_init_fromstr(&image, source, source_len)) < 0)
280 0 0 git_array_foreach(patch->hunks, i, hunk) {
0 0 git_array_foreach(patch->hunks, i, hunk) {
281 0 0 if ((error = apply_hunk(&image, patch, hunk, ctx)) < 0)
285 0 0 git_vector_foreach(&image.lines, i, line)
304 0 0 if (binary_file->datalen == 0)
310 0 0 if (!error && inflated.size != binary_file->inflatedlen) {
0 0 if (!error && inflated.size != binary_file->inflatedlen) {
315 0 0 if (error < 0)
318 0 0 if (binary_file->type == GIT_DIFF_BINARY_DELTA) {
329 0 0 else if (binary_file->type == GIT_DIFF_BINARY_LITERAL) {
351 0 0 if (!patch->binary.contains_data) {
356 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)
360 0 0 if ((error = apply_binary_delta(out, source, source_len,
365 0 0 if ((error = apply_binary_delta(&reverse, out->ptr, out->size,
370 0 0 if (source_len != reverse.size ||
0 0 if (source_len != reverse.size ||
371 0 0 (source_len && memcmp(source, reverse.ptr, source_len) != 0)) {
377 0 0 if (error < 0)
398 0 0 assert(contents_out && filename_out && mode_out && (source || !source_len) && patch);
0 0 assert(contents_out && filename_out && mode_out && (source || !source_len) && patch);
0 0 assert(contents_out && filename_out && mode_out && (source || !source_len) && patch);
0 0 assert(contents_out && filename_out && mode_out && (source || !source_len) && patch);
0 0 assert(contents_out && filename_out && mode_out && (source || !source_len) && patch);
0 0 assert(contents_out && filename_out && mode_out && (source || !source_len) && patch);
400 0 0 if (given_opts)
406 0 0 if (patch->delta->status != GIT_DELTA_DELETED) {
410 0 0 mode = newfile->mode ?
414 0 0 if (patch->delta->flags & GIT_DIFF_FLAG_BINARY)
416 0 0 else if (patch->hunks.size)
421 0 0 if (error)
434 0 0 if (error < 0)
462 0 0 if ((error = git_patch_from_diff(&patch, diff, i)) < 0)
467 0 0 if (opts->delta_cb) {
470 0 0 if (error) {
471 0 0 if (error > 0)
482 0 0 if (delta->status != GIT_DELTA_RENAMED &&
0 0 if (delta->status != GIT_DELTA_RENAMED &&
484 0 0 if (git_strmap_exists(removed_paths, delta->old_file.path)) {
497 0 0 if (delta->status != GIT_DELTA_RENAMED) {
498 0 0 if ((error = git_reader_read(&pre_contents, &pre_id, &pre_filemode,
501 0 0 } else if (error == GIT_ENOTFOUND) {
509 0 0 if (!skip_preimage && delta->status != GIT_DELTA_ADDED) {
0 0 if (!skip_preimage && delta->status != GIT_DELTA_ADDED) {
514 0 0 if (error == GIT_ENOTFOUND)
518 0 0 if (error == GIT_READER_MISMATCH)
521 0 0 if (error < 0)
539 0 0 if (preimage) {
542 0 0 pre_entry.mode = delta->old_file.mode ? delta->old_file.mode : pre_filemode;
545 0 0 if ((error = git_index_add(preimage, &pre_entry)) < 0)
550 0 0 if (delta->status != GIT_DELTA_DELETED) {
551 0 0 if ((error = git_apply__patch(&post_contents, &filename, &mode,
552 0 0 pre_contents.ptr, pre_contents.size, patch, opts)) < 0 ||
562 0 0 if ((error = git_index_add(postimage, &post_entry)) < 0)
566 0 0 if (delta->status == GIT_DELTA_RENAMED ||
0 0 if (delta->status == GIT_DELTA_RENAMED ||
570 0 0 if (delta->status == GIT_DELTA_RENAMED ||
0 0 if (delta->status == GIT_DELTA_RENAMED ||
596 0 0 if (git_strmap_new(&removed_paths) < 0)
599 0 0 for (i = 0; i < git_diff_num_deltas(diff); i++) {
600 0 0 if ((error = apply_one(repo, pre_reader, preimage, post_reader, postimage, diff, removed_paths, i, opts)) < 0)
623 0 0 assert(out && repo && preimage && diff);
0 0 assert(out && repo && preimage && diff);
0 0 assert(out && repo && preimage && diff);
0 0 assert(out && repo && preimage && diff);
627 0 0 if (given_opts)
630 0 0 if ((error = git_reader_for_tree(&pre_reader, preimage)) < 0)
637 0 0 if ((error = git_index_new(&postimage)) < 0 ||
0 0 if ((error = git_index_new(&postimage)) < 0 ||
638 0 0 (error = git_index_read_tree(postimage, preimage)) < 0 ||
647 0 0 for (i = 0; i < git_diff_num_deltas(diff); i++) {
650 0 0 if (delta->status == GIT_DELTA_DELETED ||
0 0 if (delta->status == GIT_DELTA_DELETED ||
652 0 0 if ((error = git_index_remove(postimage,
658 0 0 if ((error = apply_deltas(repo, pre_reader, NULL, post_reader, postimage, diff, &opts)) < 0)
664 0 0 if (error < 0)
693 0 0 if ((error = git_vector_init(&paths, git_diff_num_deltas(diff), NULL)) < 0)
696 0 0 for (i = 0; i < git_diff_num_deltas(diff); i++) {
699 0 0 if ((error = git_vector_insert(&paths, (void *)delta->old_file.path)) < 0)
702 0 0 if (strcmp(delta->old_file.path, delta->new_file.path) &&
0 0 if (strcmp(delta->old_file.path, delta->new_file.path) &&
711 0 0 if (location == GIT_APPLY_LOCATION_WORKDIR)
742 0 0 if ((error = git_repository_index(&index, repo)) < 0)
746 0 0 for (i = 0; i < git_diff_num_deltas(diff); i++) {
749 0 0 if (delta->status == GIT_DELTA_DELETED ||
0 0 if (delta->status == GIT_DELTA_DELETED ||
751 0 0 if ((error = git_index_remove(index, delta->old_file.path, 0)) < 0)
757 0 0 for (i = 0; i < git_index_entrycount(postimage); i++) {
760 0 0 if ((error = git_index_add(index, entry)) < 0)
771 0 0 GIT_INIT_STRUCTURE_FROM_TEMPLATE(
804 0 0 assert(repo && diff);
0 0 assert(repo && diff);
806 0 0 GIT_ERROR_CHECK_VERSION(
809 0 0 if (given_opts)
831 0 0 if (error < 0)
841 0 0 if ((error = git_index_new(&preimage)) < 0 ||
0 0 if ((error = git_index_new(&preimage)) < 0 ||
842 0 0 (error = git_index_new(&postimage)) < 0 ||
846 0 0 if (!(opts.flags & GIT_APPLY_CHECK))
847 0 0 if ((error = git_repository_index(&index, repo)) < 0 ||
0 0 if ((error = git_repository_index(&index, repo)) < 0 ||
851 0 0 if ((error = apply_deltas(repo, pre_reader, preimage, post_reader, postimage, diff, &opts)) < 0)
854 0 0 if ((opts.flags & GIT_APPLY_CHECK))
871 0 0 if (error < 0)