Branch Coverage

deps/libgit2/src/libgit2/patch_generate.c
Criterion Covered Total %
branch 137 280 48.9


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 2 48 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 ||
213 50 0 &patch->nfile, &patch->base.diff_opts)) < 0 ||
220 46 4 if (incomplete_data &&
7 39 if (incomplete_data &&
221 7 0 patch->ofile.file->mode == patch->nfile.file->mode &&
222 2 5 patch->ofile.file->mode != GIT_FILEMODE_COMMIT &&
223 0 2 git_oid_equal(&patch->ofile.file->id, &patch->nfile.file->id) &&
230 50 0 if (!error) {
231 40 10 if (patch_generated_diffable(patch))
244 49 1 ((float)patch->delta_index / patch->diff->deltas.length) : 1.0f;
246 1 49 if (!output->file_cb)
269 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))
272 0 4 if ((error = git_zstream_deflatebuf(&deflate, b_data, b_datalen)) < 0)
276 0 4 if (!git__is_ulong(deflate.size)) {
281 2 2 if (a_datalen && b_datalen) {
0 2 if (a_datalen && b_datalen) {
289 0 0 if (error == 0) {
294 0 0 } else if (error == GIT_EBUFS) {
298 0 0 if (error < 0)
302 0 4 if (delta.size && delta.size < deflate.size) {
0 0 if (delta.size && delta.size < deflate.size) {
332 2 0 if (patch->base.diff_opts.flags & GIT_DIFF_SHOW_BINARY) {
338 2 0 if ((error = create_binary(&binary.old_file.type,
342 0 2 new_data, new_len, old_data, old_len)) < 0 ||
367 0 50 if ((patch->flags & GIT_PATCH_GENERATED_DIFFED) != 0)
371 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)
374 50 0 if ((patch->flags & GIT_PATCH_GENERATED_LOADED) == 0 &&
0 50 if ((patch->flags & GIT_PATCH_GENERATED_LOADED) == 0 &&
378 10 40 if ((patch->flags & GIT_PATCH_GENERATED_DIFFABLE) == 0)
381 2 38 if ((patch->base.delta->flags & GIT_DIFF_FLAG_BINARY) != 0) {
382 2 0 if (output->binary_cb)
386 38 0 if (output->diff_cb)
396 49 0 if (diff)
415 1 0 pd->delta.status = has_new ?
1 0 pd->delta.status = has_new ?
0 0 pd->delta.status = has_new ?
419 0 1 if (git_oid_equal(&patch->nfile.file->id, &patch->ofile.file->id))
426 0 1 if (pd->delta.status == GIT_DELTA_UNMODIFIED &&
0 0 if (pd->delta.status == GIT_DELTA_UNMODIFIED &&
433 0 0 if (patch->base.diff_opts.flags & GIT_DIFF_SHOW_BINARY)
441 1 0 if (!error)
456 1 0 oldsrc->blob ? git_blob_owner(oldsrc->blob) :
457 0 0 newsrc->blob ? git_blob_owner(newsrc->blob) : NULL;
461 0 1 if ((error = patch_generated_normalize_options(&pd->patch.base.diff_opts, opts)) < 0)
464 1 0 if (opts && (opts->flags & GIT_DIFF_REVERSE) != 0) {
0 1 if (opts && (opts->flags & GIT_DIFF_REVERSE) != 0) {
471 0 1 if (!oldsrc->as_path) {
472 0 0 if (newsrc->as_path)
477 0 1 else if (!newsrc->as_path)
483 1 0 if ((error = git_diff_file_content__init_from_src(
484 0 1 ldata, repo, opts, oldsrc, lfile)) < 0 ||
498 0 0 size_t old_len = *old_path ? strlen(*old_path) : 0;
499 0 0 size_t new_len = *new_path ? strlen(*new_path) : 0;
502 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);
503 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);
504 0 0 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2);
0 0 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2);
507 0 0 GIT_ERROR_CHECK_ALLOC(pd);
511 0 0 if (*old_path) {
514 0 0 } else if (*new_path)
517 0 0 if (*new_path) {
520 0 0 } else if (*old_path)
564 0 0 GIT_ASSERT_ARG(out);
567 0 0 if ((error = patch_generated_with_delta_alloc(
575 0 0 if (!(error = patch_generated_from_sources(pd, &xo, oldsrc, newsrc, opts)))
702 49 0 if (patch_ptr) *patch_ptr = NULL;
704 0 49 if (diff_required(diff, "git_patch_from_diff") < 0)
708 0 49 if (!delta) {
713 0 49 if (git_diff_delta__should_skip(&diff->opts, delta))
717 0 49 if (!patch_ptr &&
0 0 if (!patch_ptr &&
718 0 0 ((delta->flags & DIFF_FLAGS_KNOWN_BINARY) != 0 ||
722 0 49 if ((error = patch_generated_alloc_from_diff(&patch, diff, idx)) < 0)
731 49 0 if (!error)
739 49 0 if (error || !patch_ptr)
0 49 if (error || !patch_ptr)
756 38 0 if (patch->ofile.map.len > LONG_MAX ||
0 38 if (patch->ofile.map.len > LONG_MAX ||
771 38 0 if (patch->ofile.map.len > LONG_MAX ||
0 38 if (patch->ofile.map.len > LONG_MAX ||
803 2 0 if (binary->old_file.data) {
805 0 2 GIT_ERROR_CHECK_ALLOC(patch->binary.old_file.data);
811 2 0 if (binary->new_file.data) {
813 0 2 GIT_ERROR_CHECK_ALLOC(patch->binary.new_file.data);
832 37 0 hunk = git_array_alloc(patch->base.hunks);
37 0 hunk = git_array_alloc(patch->base.hunks);
833 0 37 GIT_ERROR_CHECK_ALLOC(hunk);
858 79 0 hunk = git_array_last(patch->base.hunks);
859 0 79 GIT_ASSERT(hunk); /* programmer error if no hunk is available */
861 37 42 line = git_array_alloc(patch->base.lines);
37 0 line = git_array_alloc(patch->base.lines);
862 0 79 GIT_ERROR_CHECK_ALLOC(line);
870 43 36 if (line->origin == GIT_DIFF_LINE_ADDITION ||
13 30 if (line->origin == GIT_DIFF_LINE_ADDITION ||
873 6 24 else if (line->origin == GIT_DIFF_LINE_CONTEXT) {
876 0 24 } else if (line->origin == GIT_DIFF_LINE_CONTEXT_EOFNL)