Branch Coverage

deps/libgit2/src/patch_generate.c
Criterion Covered Total %
branch 133 274 48.5


line true false branch
48 49 1 if (patch->flags & GIT_PATCH_GENERATED_ALLOCATED)
54 47 53 if ((patch->base.delta->flags & DIFF_FLAGS_KNOWN_BINARY) != 0)
57 51 2 if ((patch->ofile.file->flags & GIT_DIFF_FLAG_BINARY) != 0 ||
0 51 if ((patch->ofile.file->flags & GIT_DIFF_FLAG_BINARY) != 0 ||
61 51 0 else if (patch->ofile.file->size > GIT_XDIFF_MAX_SIZE ||
0 51 else if (patch->ofile.file->size > GIT_XDIFF_MAX_SIZE ||
65 41 10 else if ((patch->ofile.file->flags & DIFF_FLAGS_NOT_BINARY) != 0 &&
30 11 else if ((patch->ofile.file->flags & DIFF_FLAGS_NOT_BINARY) != 0 &&
78 49 1 if (patch->diff)
86 50 0 if (opts) {
87 0 50 GIT_ERROR_CHECK_VERSION(opts, GIT_DIFF_OPTIONS_VERSION, "git_diff_options");
94 50 0 out->old_prefix = opts && opts->old_prefix ?
49 1 out->old_prefix = opts && opts->old_prefix ?
98 50 0 out->new_prefix = opts && opts->new_prefix ?
49 1 out->new_prefix = opts && opts->new_prefix ?
102 0 50 GIT_ERROR_CHECK_ALLOC(out->old_prefix);
103 0 50 GIT_ERROR_CHECK_ALLOC(out->new_prefix);
120 49 0 if ((error = patch_generated_normalize_options(
121 49 0 &patch->base.diff_opts, &diff->opts)) < 0 ||
123 0 49 &patch->ofile, diff, patch->base.delta, true)) < 0 ||
138 0 49 GIT_ERROR_CHECK_ALLOC(patch);
140 49 0 if (!(error = patch_generated_init(patch, diff, delta_index))) {
154 4 96 if ((patch->base.diff_opts.flags & GIT_DIFF_SHOW_BINARY) != 0)
164 0 50 if (patch->base.delta->status == GIT_DELTA_UNMODIFIED)
171 2 48 if ((patch->base.delta->flags & GIT_DIFF_FLAG_BINARY) != 0 &&
0 2 if ((patch->base.delta->flags & GIT_DIFF_FLAG_BINARY) != 0 &&
181 35 15 if (!olen && !nlen)
8 27 if (!olen && !nlen)
194 0 50 if ((patch->flags & GIT_PATCH_GENERATED_LOADED) != 0)
200 0 50 if ((patch->ofile.opts_flags & GIT_DIFF_SKIP_BINARY_CHECK) != 0 &&
0 0 if ((patch->ofile.opts_flags & GIT_DIFF_SKIP_BINARY_CHECK) != 0 &&
201 0 0 output && !output->binary_cb && !output->hunk_cb && !output->data_cb)
0 0 output && !output->binary_cb && !output->hunk_cb && !output->data_cb)
0 0 output && !output->binary_cb && !output->hunk_cb && !output->data_cb)
205 15 0 (((patch->ofile.flags & GIT_DIFF_FLAG__NO_DATA) != 0 ||
206 15 35 (patch->ofile.file->flags & GIT_DIFF_FLAG_VALID_ID) != 0) &&
38 12 (patch->ofile.file->flags & GIT_DIFF_FLAG_VALID_ID) != 0) &&
207 34 4 ((patch->nfile.flags & GIT_DIFF_FLAG__NO_DATA) != 0 ||
210 50 0 if ((error = git_diff_file_content__load(
211 50 0 &patch->ofile, &patch->base.diff_opts)) < 0 ||
214 50 0 if ((error = git_diff_file_content__load(
215 50 0 &patch->nfile, &patch->base.diff_opts)) < 0 ||
222 46 4 if (incomplete_data &&
7 39 if (incomplete_data &&
223 7 0 patch->ofile.file->mode == patch->nfile.file->mode &&
224 2 5 patch->ofile.file->mode != GIT_FILEMODE_COMMIT &&
225 0 2 git_oid_equal(&patch->ofile.file->id, &patch->nfile.file->id) &&
232 50 0 if (!error) {
233 40 10 if (patch_generated_diffable(patch))
246 49 1 ((float)patch->delta_index / patch->diff->deltas.length) : 1.0f;
248 1 49 if (!output->file_cb)
271 4 0 if (!git__is_ulong(a_datalen) || !git__is_ulong(b_datalen))
0 4 if (!git__is_ulong(a_datalen) || !git__is_ulong(b_datalen))
274 0 4 if ((error = git_zstream_deflatebuf(&deflate, b_data, b_datalen)) < 0)
278 0 4 if (!git__is_ulong(deflate.size)) {
283 2 2 if (a_datalen && b_datalen) {
0 2 if (a_datalen && b_datalen) {
291 0 0 if (error == 0) {
296 0 0 } else if (error == GIT_EBUFS) {
300 0 0 if (error < 0)
304 0 4 if (delta.size && delta.size < deflate.size) {
0 0 if (delta.size && delta.size < deflate.size) {
334 2 0 if (patch->base.diff_opts.flags & GIT_DIFF_SHOW_BINARY) {
340 2 0 if ((error = create_binary(&binary.old_file.type,
344 0 2 new_data, new_len, old_data, old_len)) < 0 ||
369 0 50 if ((patch->flags & GIT_PATCH_GENERATED_DIFFED) != 0)
373 1 49 if (!output->binary_cb && !output->hunk_cb && !output->data_cb)
0 1 if (!output->binary_cb && !output->hunk_cb && !output->data_cb)
0 0 if (!output->binary_cb && !output->hunk_cb && !output->data_cb)
376 50 0 if ((patch->flags & GIT_PATCH_GENERATED_LOADED) == 0 &&
0 50 if ((patch->flags & GIT_PATCH_GENERATED_LOADED) == 0 &&
380 10 40 if ((patch->flags & GIT_PATCH_GENERATED_DIFFABLE) == 0)
383 2 38 if ((patch->base.delta->flags & GIT_DIFF_FLAG_BINARY) != 0) {
384 2 0 if (output->binary_cb)
388 38 0 if (output->diff_cb)
398 49 0 if (diff)
417 1 0 pd->delta.status = has_new ?
1 0 pd->delta.status = has_new ?
0 0 pd->delta.status = has_new ?
421 0 1 if (git_oid_equal(&patch->nfile.file->id, &patch->ofile.file->id))
428 0 1 if (pd->delta.status == GIT_DELTA_UNMODIFIED &&
0 0 if (pd->delta.status == GIT_DELTA_UNMODIFIED &&
435 0 0 if (patch->base.diff_opts.flags & GIT_DIFF_SHOW_BINARY)
443 1 0 if (!error)
458 1 0 oldsrc->blob ? git_blob_owner(oldsrc->blob) :
459 0 0 newsrc->blob ? git_blob_owner(newsrc->blob) : NULL;
463 0 1 if ((error = patch_generated_normalize_options(&pd->patch.base.diff_opts, opts)) < 0)
466 1 0 if (opts && (opts->flags & GIT_DIFF_REVERSE) != 0) {
0 1 if (opts && (opts->flags & GIT_DIFF_REVERSE) != 0) {
473 0 1 if (!oldsrc->as_path) {
474 0 0 if (newsrc->as_path)
479 0 1 else if (!newsrc->as_path)
485 1 0 if ((error = git_diff_file_content__init_from_src(
486 0 1 ldata, repo, opts, oldsrc, lfile)) < 0 ||
500 0 0 size_t old_len = *old_path ? strlen(*old_path) : 0;
501 0 0 size_t new_len = *new_path ? strlen(*new_path) : 0;
504 0 0 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*pd), old_len);
0 0 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*pd), old_len);
505 0 0 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, new_len);
0 0 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, new_len);
506 0 0 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2);
0 0 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2);
509 0 0 GIT_ERROR_CHECK_ALLOC(pd);
513 0 0 if (*old_path) {
516 0 0 } else if (*new_path)
519 0 0 if (*new_path) {
522 0 0 } else if (*old_path)
566 0 0 assert(out);
569 0 0 if ((error = patch_generated_with_delta_alloc(
577 0 0 if (!(error = patch_generated_from_sources(pd, &xo, oldsrc, newsrc, opts)))
704 49 0 if (patch_ptr) *patch_ptr = NULL;
706 0 49 if (diff_required(diff, "git_patch_from_diff") < 0)
710 0 49 if (!delta) {
715 0 49 if (git_diff_delta__should_skip(&diff->opts, delta))
719 0 49 if (!patch_ptr &&
0 0 if (!patch_ptr &&
720 0 0 ((delta->flags & DIFF_FLAGS_KNOWN_BINARY) != 0 ||
724 0 49 if ((error = patch_generated_alloc_from_diff(&patch, diff, idx)) < 0)
733 49 0 if (!error)
741 49 0 if (error || !patch_ptr)
0 49 if (error || !patch_ptr)
789 2 0 if (binary->old_file.data) {
791 0 2 GIT_ERROR_CHECK_ALLOC(patch->binary.old_file.data);
797 2 0 if (binary->new_file.data) {
799 0 2 GIT_ERROR_CHECK_ALLOC(patch->binary.new_file.data);
818 37 0 hunk = git_array_alloc(patch->base.hunks);
0 0 hunk = git_array_alloc(patch->base.hunks);
819 0 37 GIT_ERROR_CHECK_ALLOC(hunk);
844 79 0 hunk = git_array_last(patch->base.hunks);
845 0 79 assert(hunk); /* programmer error if no hunk is available */
847 37 42 line = git_array_alloc(patch->base.lines);
42 0 line = git_array_alloc(patch->base.lines);
848 0 79 GIT_ERROR_CHECK_ALLOC(line);
856 43 36 if (line->origin == GIT_DIFF_LINE_ADDITION ||
13 30 if (line->origin == GIT_DIFF_LINE_ADDITION ||
859 6 24 else if (line->origin == GIT_DIFF_LINE_CONTEXT) {
862 0 24 } else if (line->origin == GIT_DIFF_LINE_CONTEXT_EOFNL)