Branch Coverage

deps/libgit2/src/diff_print.c
Criterion Covered Total %
branch 131 250 52.4


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 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);
355 2 0 if (delta->status == GIT_DELTA_RENAMED)
360 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 ||
361 2 0 (error = git_buf_puts(&new_path, delta->new_file.path)) < 0 ||
362 2 0 (error = git_buf_quote(&old_path)) < 0 ||
374 0 2 if (git_buf_oom(out))
390 23 0 if (delta->old_file.mode == GIT_FILEMODE_COMMIT ||
0 23 if (delta->old_file.mode == GIT_FILEMODE_COMMIT ||
394 1 22 if (git_oid_equal(&delta->old_file.id, &delta->new_file.id))
412 0 23 if (!oldpfx)
414 0 23 if (!newpfx)
416 0 23 if (!id_strlen)
419 23 0 if ((error = diff_delta_format_path(
420 23 0 &old_path, oldpfx, delta->old_file.path)) < 0 ||
430 1 22 if (unchanged && delta->old_file.mode != delta->new_file.mode)
0 1 if (unchanged && delta->old_file.mode != delta->new_file.mode)
433 21 2 if (delta->status == GIT_DELTA_RENAMED ||
0 21 if (delta->status == GIT_DELTA_RENAMED ||
434 0 0 (delta->status == GIT_DELTA_COPIED && unchanged)) {
435 0 2 if ((error = diff_delta_format_similarity_header(out, delta)) < 0)
439 22 1 if (!unchanged) {
440 0 22 if ((error = diff_print_oid_range(out, delta,
444 21 1 if ((delta->flags & GIT_DIFF_FLAG_BINARY) == 0)
449 0 23 if (git_buf_oom(out))
467 0 2 "delta" : "literal";
473 2 2 for (scan = data, end = data + datalen; scan < end; ) {
475 0 2 if (chunk_len > 52)
478 2 0 if (chunk_len <= 26)
486 0 2 if (git_buf_oom(pi->buf))
494 0 2 if (git_buf_oom(pi->buf))
507 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 ||
508 0 0 (error = diff_delta_format_path(&new_path, new_pfx, delta->new_file.path)) < 0 ||
529 0 1 if (delta->status == GIT_DELTA_UNMODIFIED)
532 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)
540 1 0 if ((error = format_binary(pi, binary->new_file.type, binary->new_file.data,
541 0 1 binary->new_file.datalen, binary->new_file.inflatedlen)) < 0 ||
544 0 0 if (error == GIT_EBUFS) {
563 21 2 pi->old_prefix ? pi->old_prefix : DIFF_OLD_PREFIX_DEFAULT;
565 21 2 pi->new_prefix ? pi->new_prefix : DIFF_NEW_PREFIX_DEFAULT;
567 22 1 bool binary = (delta->flags & GIT_DIFF_FLAG_BINARY) ||
0 22 bool binary = (delta->flags & GIT_DIFF_FLAG_BINARY) ||
573 1 22 if (binary && show_binary)
1 0 if (binary && show_binary)
574 1 0 id_strlen = delta->old_file.id_abbrev ? delta->old_file.id_abbrev :
579 23 0 if (S_ISDIR(delta->new_file.mode) ||
23 0 if (S_ISDIR(delta->new_file.mode) ||
580 23 0 delta->status == GIT_DELTA_UNMODIFIED ||
581 23 0 delta->status == GIT_DELTA_IGNORED ||
582 0 23 delta->status == GIT_DELTA_UNREADABLE ||
583 0 0 (delta->status == GIT_DELTA_UNTRACKED &&
587 0 23 if ((error = git_diff_delta__format_file_header(pi->buf, delta, oldpfx, newpfx,
605 1 0 pi->old_prefix ? pi->old_prefix : DIFF_OLD_PREFIX_DEFAULT;
607 1 0 pi->new_prefix ? pi->new_prefix : DIFF_NEW_PREFIX_DEFAULT;
612 0 1 if ((error = diff_print_patch_file_binary(
630 0 17 if (S_ISDIR(d->new_file.mode))
648 0 38 if (S_ISDIR(delta->new_file.mode))
698 0 14 if ((error = diff_print_info_init_fromdiff(&pi, &buf, diff, format, print_cb, payload)) < 0)
701 0 14 if ((error = git_diff_foreach(diff, print_file, print_binary, print_hunk, print_line, &pi)) != 0) {
720 0 44 if (!output) {
725 34 10 if (line->origin == GIT_DIFF_LINE_ADDITION ||
32 2 if (line->origin == GIT_DIFF_LINE_ADDITION ||
726 5 27 line->origin == GIT_DIFF_LINE_DELETION ||
739 0 0 FILE *fp = payload ? payload : stdout;
745 0 0 if (line->origin == GIT_DIFF_LINE_CONTEXT ||
0 0 if (line->origin == GIT_DIFF_LINE_CONTEXT ||
746 0 0 line->origin == GIT_DIFF_LINE_ADDITION ||
748 0 0 while ((error = fputc(line->origin, fp)) == EINTR)
750 0 0 if (error) {
756 0 0 if (fwrite(line->content, line->content_len, 1, fp) != 1) {
767 1 0 assert(out && diff);
0 1 assert(out && diff);
782 10 0 assert(patch && print_cb);
0 10 assert(patch && print_cb);
784 0 10 if ((error = diff_print_info_init_frompatch(&pi, &temp, patch,
788 0 10 if ((error = git_patch__invoke_callbacks(patch, diff_print_patch_file, diff_print_patch_binary,
802 10 0 assert(out && patch);
0 10 assert(out && patch);