Branch Coverage

deps/libgit2/src/libgit2/diff_print.c
Criterion Covered Total %
branch 136 260 52.3


line true false branch
49 24 0 if (!pi->id_strlen) {
50 1 23 if (!repo)
52 0 23 else if (git_repository__configmap_lookup(&pi->id_strlen, repo, GIT_CONFIGMAP_ABBREV) < 0)
56 0 24 if (pi->id_strlen > GIT_OID_HEXSZ)
75 14 0 git_repository *repo = diff ? diff->repo : NULL;
79 14 0 if (diff) {
99 0 10 GIT_ASSERT_ARG(patch);
113 0 6 if (S_ISDIR(mode))
115 0 6 else if (GIT_PERMS_IS_EXEC(mode)) /* -V536 */
150 2 0 if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 &&
0 2 if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 &&
157 0 2 if (git_str_oom(out))
174 3 0 pi->strcomp : git__strcmp;
178 3 0 if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 && code == ' ')
0 3 if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 && code == ' ')
190 3 0 else if (delta->old_file.mode != delta->new_file.mode &&
0 3 else if (delta->old_file.mode != delta->new_file.mode &&
191 0 0 delta->old_file.mode != 0 && delta->new_file.mode != 0)
194 0 3 else if (old_suffix != ' ')
198 0 3 if (git_str_oom(out))
219 2 0 if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 && code == ' ')
0 2 if ((pi->flags & GIT_DIFF_SHOW_UNMODIFIED) == 0 && code == ' ')
224 0 2 id_abbrev = delta->old_file.mode ? delta->old_file.id_abbrev :
227 0 2 if (pi->id_strlen > id_abbrev) {
237 2 0 git_str_printf(
242 0 2 if (delta->similarity > 0)
245 0 2 if (delta->old_file.path != delta->new_file.path)
249 2 0 git_str_printf(
253 0 2 if (git_str_oom(out))
269 0 0 return git_str_oom(out) ? -1 : 0;
278 7 15 if (delta->old_file.mode &&
0 7 if (delta->old_file.mode &&
286 19 3 if ((delta->new_file.mode &&
0 19 if ((delta->new_file.mode &&
297 4 18 if (delta->old_file.mode == delta->new_file.mode) {
298 3 1 if (print_index)
302 15 3 if (delta->old_file.mode == 0)
304 3 0 else if (delta->new_file.mode == 0)
309 17 1 if (print_index)
313 0 22 return git_str_oom(out) ? -1 : 0;
319 0 46 if (!filename) {
324 0 46 if (git_str_joinpath(out, prefix, filename) < 0)
337 15 6 if (git_oid_is_zero(&delta->old_file.id))
340 2 19 if (git_oid_is_zero(&delta->new_file.id))
354 0 2 if (delta->similarity > 100) {
360 0 2 GIT_ASSERT(delta->status == GIT_DELTA_RENAMED || delta->status == GIT_DELTA_COPIED);
0 0 GIT_ASSERT(delta->status == GIT_DELTA_RENAMED || delta->status == GIT_DELTA_COPIED);
361 2 0 if (delta->status == GIT_DELTA_RENAMED)
366 2 0 if ((error = git_str_puts(&old_path, delta->old_file.path)) < 0 ||
2 0 if ((error = git_str_puts(&old_path, delta->old_file.path)) < 0 ||
367 2 0 (error = git_str_puts(&new_path, delta->new_file.path)) < 0 ||
368 2 0 (error = git_str_quote(&old_path)) < 0 ||
380 0 2 if (git_str_oom(out))
396 23 0 if (delta->old_file.mode == GIT_FILEMODE_COMMIT ||
0 23 if (delta->old_file.mode == GIT_FILEMODE_COMMIT ||
400 1 22 if (git_oid_equal(&delta->old_file.id, &delta->new_file.id))
418 0 23 if (!oldpfx)
420 0 23 if (!newpfx)
422 0 23 if (!id_strlen)
425 23 0 if ((error = diff_delta_format_path(
426 23 0 &old_path, oldpfx, delta->old_file.path)) < 0 ||
436 1 22 if (unchanged && delta->old_file.mode != delta->new_file.mode)
0 1 if (unchanged && delta->old_file.mode != delta->new_file.mode)
439 21 2 if (delta->status == GIT_DELTA_RENAMED ||
0 21 if (delta->status == GIT_DELTA_RENAMED ||
440 0 0 (delta->status == GIT_DELTA_COPIED && unchanged)) {
441 0 2 if ((error = diff_delta_format_similarity_header(out, delta)) < 0)
445 22 1 if (!unchanged) {
446 0 22 if ((error = diff_print_oid_range(out, delta,
450 21 1 if ((delta->flags & GIT_DIFF_FLAG_BINARY) == 0)
455 0 23 if (git_str_oom(out))
473 0 2 "delta" : "literal";
479 2 2 for (scan = data, end = data + datalen; scan < end; ) {
481 0 2 if (chunk_len > 52)
484 2 0 if (chunk_len <= 26)
492 0 2 if (git_str_oom(pi->buf))
500 0 2 if (git_str_oom(pi->buf))
513 0 0 if ((error = diff_delta_format_path(&old_path, old_pfx, delta->old_file.path)) < 0 ||
0 0 if ((error = diff_delta_format_path(&old_path, old_pfx, delta->old_file.path)) < 0 ||
514 0 0 (error = diff_delta_format_path(&new_path, new_pfx, delta->new_file.path)) < 0 ||
535 0 1 if (delta->status == GIT_DELTA_UNMODIFIED)
538 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)
546 1 0 if ((error = format_binary(pi, binary->new_file.type, binary->new_file.data,
547 0 1 binary->new_file.datalen, binary->new_file.inflatedlen)) < 0 ||
550 0 0 if (error == GIT_EBUFS) {
569 21 2 pi->old_prefix ? pi->old_prefix : DIFF_OLD_PREFIX_DEFAULT;
571 21 2 pi->new_prefix ? pi->new_prefix : DIFF_NEW_PREFIX_DEFAULT;
573 22 1 bool binary = (delta->flags & GIT_DIFF_FLAG_BINARY) ||
0 22 bool binary = (delta->flags & GIT_DIFF_FLAG_BINARY) ||
579 1 22 if (binary && show_binary)
1 0 if (binary && show_binary)
580 1 0 id_strlen = delta->old_file.id_abbrev ? delta->old_file.id_abbrev :
585 23 0 if (S_ISDIR(delta->new_file.mode) ||
23 0 if (S_ISDIR(delta->new_file.mode) ||
586 23 0 delta->status == GIT_DELTA_UNMODIFIED ||
587 23 0 delta->status == GIT_DELTA_IGNORED ||
588 0 23 delta->status == GIT_DELTA_UNREADABLE ||
589 0 0 (delta->status == GIT_DELTA_UNTRACKED &&
593 0 23 if ((error = git_diff_delta__format_file_header(pi->buf, delta, oldpfx, newpfx,
611 1 0 pi->old_prefix ? pi->old_prefix : DIFF_OLD_PREFIX_DEFAULT;
613 1 0 pi->new_prefix ? pi->new_prefix : DIFF_NEW_PREFIX_DEFAULT;
618 0 1 if ((error = diff_print_patch_file_binary(
636 0 17 if (S_ISDIR(d->new_file.mode))
654 0 38 if (S_ISDIR(delta->new_file.mode))
704 0 14 if ((error = diff_print_info_init_fromdiff(&pi, &buf, diff, format, print_cb, payload)) < 0)
707 0 14 if ((error = git_diff_foreach(diff, print_file, print_binary, print_hunk, print_line, &pi)) != 0) {
726 0 44 if (!output) {
731 34 10 if (line->origin == GIT_DIFF_LINE_ADDITION ||
32 2 if (line->origin == GIT_DIFF_LINE_ADDITION ||
732 5 27 line->origin == GIT_DIFF_LINE_DELETION ||
745 0 0 FILE *fp = payload ? payload : stdout;
751 0 0 if (line->origin == GIT_DIFF_LINE_CONTEXT ||
0 0 if (line->origin == GIT_DIFF_LINE_CONTEXT ||
752 0 0 line->origin == GIT_DIFF_LINE_ADDITION ||
754 0 0 while ((error = fputc(line->origin, fp)) == EINTR)
756 0 0 if (error) {
762 0 0 if (fwrite(line->content, line->content_len, 1, fp) != 1) {
776 0 1 GIT_ASSERT_ARG(out);
777 0 1 GIT_ASSERT_ARG(diff);
779 1 0 if ((error = git_buf_tostr(&str, out)) < 0 ||
1 0 if ((error = git_buf_tostr(&str, out)) < 0 ||
800 0 10 GIT_ASSERT_ARG(patch);
801 0 10 GIT_ASSERT_ARG(print_cb);
803 0 10 if ((error = diff_print_info_init_frompatch(&pi, &temp, patch,
807 0 10 if ((error = git_patch__invoke_callbacks(patch, diff_print_patch_file, diff_print_patch_binary,
821 7 0 GIT_BUF_WRAP_PRIVATE(out, git_patch__to_buf, patch);
7 0 GIT_BUF_WRAP_PRIVATE(out, git_patch__to_buf, patch);
826 0 10 GIT_ASSERT_ARG(out);
827 0 10 GIT_ASSERT_ARG(patch);