Branch Coverage

deps/libgit2/src/diff_print.c
Criterion Covered Total %
branch 129 238 54.2


line true false branch
48 24 0 if (!pi->id_strlen) {
49 1 23 if (!repo)
51 0 23 else if (git_repository__configmap_lookup(&pi->id_strlen, repo, GIT_CONFIGMAP_ABBREV) < 0)
55 0 24 if (pi->id_strlen > GIT_OID_HEXSZ)
74 14 0 git_repository *repo = diff ? diff->repo : NULL;
78 14 0 if (diff) {
98 0 10 assert(patch);
112 0 6 if (S_ISDIR(mode))
114 0 6 else if (GIT_PERMS_IS_EXEC(mode)) /* -V536 */
149 2 0 if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 &&
0 2 if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 &&
156 0 2 if (git_buf_oom(out))
173 3 0 pi->strcomp : git__strcmp;
177 3 0 if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 && code == ' ')
0 3 if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 && code == ' ')
189 3 0 else if (delta->old_file.mode != delta->new_file.mode &&
0 3 else if (delta->old_file.mode != delta->new_file.mode &&
190 0 0 delta->old_file.mode != 0 && delta->new_file.mode != 0)
193 0 3 else if (old_suffix != ' ')
197 0 3 if (git_buf_oom(out))
218 2 0 if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 && code == ' ')
0 2 if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 && code == ' ')
223 0 2 id_abbrev = delta->old_file.mode ? delta->old_file.id_abbrev :
226 0 2 if (pi->id_strlen > id_abbrev) {
236 2 0 git_buf_printf(
241 0 2 if (delta->similarity > 0)
244 0 2 if (delta->old_file.path != delta->new_file.path)
248 2 0 git_buf_printf(
252 0 2 if (git_buf_oom(out))
268 0 0 return git_buf_oom(out) ? -1 : 0;
277 7 15 if (delta->old_file.mode &&
0 7 if (delta->old_file.mode &&
285 19 3 if ((delta->new_file.mode &&
0 19 if ((delta->new_file.mode &&
296 4 18 if (delta->old_file.mode == delta->new_file.mode) {
297 3 1 if (print_index)
301 15 3 if (delta->old_file.mode == 0)
303 3 0 else if (delta->new_file.mode == 0)
308 17 1 if (print_index)
312 0 22 return git_buf_oom(out) ? -1 : 0;
318 0 46 if (git_buf_joinpath(out, prefix, filename) < 0)
331 15 6 if (git_oid_is_zero(&delta->old_file.id))
334 2 19 if (git_oid_is_zero(&delta->new_file.id))
348 0 2 if (delta->similarity > 100) {
354 2 0 if (delta->status == GIT_DELTA_RENAMED)
356 0 0 else if (delta->status == GIT_DELTA_COPIED)
361 2 0 if ((error = git_buf_puts(&old_path, delta->old_file.path)) < 0 ||
2 0 if ((error = git_buf_puts(&old_path, delta->old_file.path)) < 0 ||
362 2 0 (error = git_buf_puts(&new_path, delta->new_file.path)) < 0 ||
363 2 0 (error = git_buf_quote(&old_path)) < 0 ||
375 0 2 if (git_buf_oom(out))
391 23 0 if (delta->old_file.mode == GIT_FILEMODE_COMMIT ||
0 23 if (delta->old_file.mode == GIT_FILEMODE_COMMIT ||
395 1 22 if (git_oid_equal(&delta->old_file.id, &delta->new_file.id))
413 0 23 if (!oldpfx)
415 0 23 if (!newpfx)
417 0 23 if (!id_strlen)
420 23 0 if ((error = diff_delta_format_path(
421 23 0 &old_path, oldpfx, delta->old_file.path)) < 0 ||
431 1 22 if (unchanged && delta->old_file.mode != delta->new_file.mode)
0 1 if (unchanged && delta->old_file.mode != delta->new_file.mode)
434 21 2 if (delta->status == GIT_DELTA_RENAMED ||
0 21 if (delta->status == GIT_DELTA_RENAMED ||
435 0 0 (delta->status == GIT_DELTA_COPIED && unchanged)) {
436 0 2 if ((error = diff_delta_format_similarity_header(out, delta)) < 0)
440 22 1 if (!unchanged) {
441 0 22 if ((error = diff_print_oid_range(out, delta,
445 21 1 if ((delta->flags & GIT_DIFF_FLAG_BINARY) == 0)
450 0 23 if (git_buf_oom(out))
468 0 2 "delta" : "literal";
474 2 2 for (scan = data, end = data + datalen; scan < end; ) {
476 0 2 if (chunk_len > 52)
479 2 0 if (chunk_len <= 26)
487 0 2 if (git_buf_oom(pi->buf))
505 0 0 if ((error = diff_delta_format_path(
506 0 0 &old_path, old_pfx, delta->old_file.path)) < 0 ||
531 0 1 if (delta->status == GIT_DELTA_UNMODIFIED)
534 1 0 if ((pi->flags & GIT_DIFF_SHOW_BINARY) == 0 || !binary->contains_data)
0 1 if ((pi->flags & GIT_DIFF_SHOW_BINARY) == 0 || !binary->contains_data)
542 1 0 if ((error = format_binary(pi, binary->new_file.type, binary->new_file.data,
543 0 1 binary->new_file.datalen, binary->new_file.inflatedlen)) < 0 ||
547 0 0 if (error == GIT_EBUFS) {
566 21 2 pi->old_prefix ? pi->old_prefix : DIFF_OLD_PREFIX_DEFAULT;
568 21 2 pi->new_prefix ? pi->new_prefix : DIFF_NEW_PREFIX_DEFAULT;
570 22 1 bool binary = (delta->flags & GIT_DIFF_FLAG_BINARY) ||
0 22 bool binary = (delta->flags & GIT_DIFF_FLAG_BINARY) ||
576 1 22 if (binary && show_binary)
1 0 if (binary && show_binary)
577 1 0 id_strlen = delta->old_file.id_abbrev ? delta->old_file.id_abbrev :
582 23 0 if (S_ISDIR(delta->new_file.mode) ||
23 0 if (S_ISDIR(delta->new_file.mode) ||
583 23 0 delta->status == GIT_DELTA_UNMODIFIED ||
584 23 0 delta->status == GIT_DELTA_IGNORED ||
585 0 23 delta->status == GIT_DELTA_UNREADABLE ||
586 0 0 (delta->status == GIT_DELTA_UNTRACKED &&
590 0 23 if ((error = git_diff_delta__format_file_header(
609 1 0 pi->old_prefix ? pi->old_prefix : DIFF_OLD_PREFIX_DEFAULT;
611 1 0 pi->new_prefix ? pi->new_prefix : DIFF_NEW_PREFIX_DEFAULT;
616 0 1 if ((error = diff_print_patch_file_binary(
634 0 17 if (S_ISDIR(d->new_file.mode))
652 0 38 if (S_ISDIR(delta->new_file.mode))
702 14 0 if (!(error = diff_print_info_init_fromdiff(
707 0 14 if (error) /* make sure error message is set */
725 0 44 if (!output) {
730 34 10 if (line->origin == GIT_DIFF_LINE_ADDITION ||
32 2 if (line->origin == GIT_DIFF_LINE_ADDITION ||
731 5 27 line->origin == GIT_DIFF_LINE_DELETION ||
744 0 0 FILE *fp = payload ? payload : stdout;
748 0 0 if (line->origin == GIT_DIFF_LINE_CONTEXT ||
0 0 if (line->origin == GIT_DIFF_LINE_CONTEXT ||
749 0 0 line->origin == GIT_DIFF_LINE_ADDITION ||
759 1 0 assert(out && diff);
0 1 assert(out && diff);
775 10 0 assert(patch && print_cb);
0 10 assert(patch && print_cb);
777 10 0 if (!(error = diff_print_info_init_frompatch(
787 0 10 if (error) /* make sure error message is set */
799 10 0 assert(out && patch);
0 10 assert(out && patch);