Branch Coverage

deps/libgit2/src/diff_tform.c
Criterion Covered Total %
branch 211 458 46.0


line true false branch
24 0 27 if (!delta)
30 27 0 if (d->old_file.path != NULL) {
32 0 27 if (delta->old_file.path == NULL)
36 0 27 if (d->new_file.path != d->old_file.path && d->new_file.path != NULL) {
0 0 if (d->new_file.path != d->old_file.path && d->new_file.path != NULL) {
38 0 0 if (delta->new_file.path == NULL)
71 0 3 if (b->status == GIT_DELTA_CONFLICTED)
73 0 3 if (a->status == GIT_DELTA_CONFLICTED)
77 3 0 if (b->status == GIT_DELTA_UNMODIFIED || a->status == GIT_DELTA_DELETED)
0 3 if (b->status == GIT_DELTA_UNMODIFIED || a->status == GIT_DELTA_DELETED)
81 0 3 if ((dup = git_diff__delta_dup(b, pool)) == NULL)
85 3 0 if (a->status == GIT_DELTA_UNMODIFIED ||
3 0 if (a->status == GIT_DELTA_UNMODIFIED ||
86 0 3 a->status == GIT_DELTA_UNTRACKED ||
90 0 3 assert(b->status != GIT_DELTA_UNMODIFIED);
95 0 3 if (dup->status == GIT_DELTA_DELETED) {
96 0 0 if (a->status == GIT_DELTA_ADDED) {
124 6 0 assert(onto && from);
0 6 assert(onto && from);
126 2 4 if (!from->deltas.length)
132 4 0 if (ignore_case != ((from->opts.flags & GIT_DIFF_IGNORE_CASE) != 0) ||
0 4 if (ignore_case != ((from->opts.flags & GIT_DIFF_IGNORE_CASE) != 0) ||
139 0 4 if (git_vector_init(&onto_new, onto->deltas.length, git_diff_delta__cmp) < 0)
144 18 13 for (i = 0, j = 0; i < onto->deltas.length || j < from->deltas.length; ) {
9 4 for (i = 0, j = 0; i < onto->deltas.length || j < from->deltas.length; ) {
145 18 9 git_diff_delta *o = GIT_VECTOR_GET(&onto->deltas, i);
146 27 0 const git_diff_delta *f = GIT_VECTOR_GET(&from->deltas, j);
147 27 0 int cmp = !f ? -1 : !o ? 1 :
18 9 int cmp = !f ? -1 : !o ? 1 :
148 0 18 STRCMP_CASESELECT(ignore_case, o->old_file.path, f->old_file.path);
150 0 27 if (cmp < 0) {
153 24 3 } else if (cmp > 0) {
157 0 3 const git_diff_delta *left = reversed ? f : o;
158 0 3 const git_diff_delta *right = reversed ? o : f;
168 27 0 if (delta && git_diff_delta__should_skip(&onto->opts, delta)) {
0 27 if (delta && git_diff_delta__should_skip(&onto->opts, delta)) {
173 27 0 if ((error = !delta ? -1 : git_vector_insert(&onto_new, delta)) < 0)
0 27 if ((error = !delta ? -1 : git_vector_insert(&onto_new, delta)) < 0)
177 4 0 if (!error) {
181 0 4 if ((onto->opts.flags & GIT_DIFF_REVERSE) != 0)
235 0 7 if (error < 0)
254 0 11 GIT_ERROR_CHECK_VERSION(given, GIT_DIFF_FIND_OPTIONS_VERSION, "git_diff_find_options");
260 11 0 if (given)
263 11 0 if (!given ||
2 9 if (!given ||
266 2 0 if (cfg) {
271 2 0 if (!git__parse_bool(&boolval, rule) && !boolval)
0 2 if (!git__parse_bool(&boolval, rule) && !boolval)
273 2 0 else if (!strcasecmp(rule, "copies") || !strcasecmp(rule, "copy"))
0 2 else if (!strcasecmp(rule, "copies") || !strcasecmp(rule, "copy"))
287 0 11 if (opts->flags & GIT_DIFF_FIND_EXACT_MATCH_ONLY) {
297 0 11 if (opts->flags & GIT_DIFF_FIND_RENAMES_FROM_REWRITES)
300 0 11 if (opts->flags & GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED)
303 1 10 if (opts->flags & GIT_DIFF_BREAK_REWRITES)
308 1 10 if (USE_DEFAULT(opts->rename_threshold))
0 1 if (USE_DEFAULT(opts->rename_threshold))
311 1 10 if (USE_DEFAULT(opts->rename_from_rewrite_threshold))
0 1 if (USE_DEFAULT(opts->rename_from_rewrite_threshold))
314 1 10 if (USE_DEFAULT(opts->copy_threshold))
0 1 if (USE_DEFAULT(opts->copy_threshold))
317 1 10 if (USE_DEFAULT(opts->break_rewrite_threshold))
0 1 if (USE_DEFAULT(opts->break_rewrite_threshold))
322 10 1 if (!opts->rename_limit) {
323 10 0 if (cfg) {
328 0 10 if (opts->rename_limit <= 0)
333 11 0 if (!opts->metric) {
335 0 11 GIT_ERROR_CHECK_ALLOC(opts->metric);
342 1 10 if (opts->flags & GIT_DIFF_FIND_IGNORE_WHITESPACE)
344 0 10 else if (opts->flags & GIT_DIFF_FIND_DONT_IGNORE_WHITESPACE)
360 0 0 GIT_ERROR_CHECK_ALLOC(deleted);
378 0 6 if (git_vector_init(&onto, expected_size, git_diff_delta__cmp) < 0)
382 15 6 git_vector_foreach(&diff->deltas, i, delta) {
383 6 9 if ((delta->flags & GIT_DIFF_FLAG__TO_DELETE) != 0)
386 0 9 if ((delta->flags & GIT_DIFF_FLAG__TO_SPLIT) != 0 && actually_split) {
0 0 if ((delta->flags & GIT_DIFF_FLAG__TO_SPLIT) != 0 && actually_split) {
389 0 0 if (insert_delete_side_of_split(diff, &onto, delta) < 0)
392 0 0 if (diff->new_src == GIT_ITERATOR_WORKDIR)
405 9 0 if (delta->status != GIT_DELTA_COPIED &&
3 6 if (delta->status != GIT_DELTA_COPIED &&
406 0 3 delta->status != GIT_DELTA_RENAMED &&
407 0 0 (delta->status != GIT_DELTA_MODIFIED || actually_split))
411 0 9 if (git_vector_insert(&onto, delta) < 0)
418 15 6 git_vector_foreach(&diff->deltas, i, delta) {
419 6 9 if ((delta->flags & GIT_DIFF_FLAG__TO_DELETE) != 0)
439 17 14 return (idx & 1) ? &delta->new_file : &delta->old_file;
456 7 4 info->src = (file_idx & 1) ? diff->new_src : diff->old_src;
463 4 7 if (info->file->size > 0 || info->src == GIT_ITERATOR_WORKDIR)
0 4 if (info->file->size > 0 || info->src == GIT_ITERATOR_WORKDIR)
478 5 6 if (info->src == GIT_ITERATOR_WORKDIR) {
479 0 5 if ((error = git_buf_joinpath(
484 0 5 if (!git_path_isfile(info->data.ptr))
496 0 6 if (info->odb_obj != NULL)
503 0 6 if (error < 0) {
510 0 6 if (file->size != git_blob_rawsize(info->blob))
513 6 0 sz = git__is_sizet(file->size) ? (size_t)file->size : (size_t)-1;
526 0 14 if (info->odb_obj)
529 6 8 if (info->blob)
558 10 0 if (!GIT_MODE_ISBLOB(a_file->mode) || !GIT_MODE_ISBLOB(b_file->mode))
0 10 if (!GIT_MODE_ISBLOB(a_file->mode) || !GIT_MODE_ISBLOB(b_file->mode))
562 0 10 if (exact_match) {
563 0 0 if (git_oid_is_zero(&a_file->id) &&
0 0 if (git_oid_is_zero(&a_file->id) &&
564 0 0 diff->old_src == GIT_ITERATOR_WORKDIR &&
569 0 0 if (git_oid_is_zero(&b_file->id) &&
0 0 if (git_oid_is_zero(&b_file->id) &&
570 0 0 diff->new_src == GIT_ITERATOR_WORKDIR &&
577 3 7 if (git_oid__cmp(&a_file->id, &b_file->id) == 0) {
583 0 7 if (exact_match) {
592 4 3 if (!cache[a_idx] && (error = similarity_init(&a_info, diff, a_idx)) < 0)
0 4 if (!cache[a_idx] && (error = similarity_init(&a_info, diff, a_idx)) < 0)
594 7 0 if (!cache[b_idx] && (error = similarity_init(&b_info, diff, b_idx)) < 0)
0 7 if (!cache[b_idx] && (error = similarity_init(&b_info, diff, b_idx)) < 0)
598 0 7 if (a_file->size > 127 &&
0 0 if (a_file->size > 127 &&
599 0 0 b_file->size > 127 &&
600 0 0 (a_file->size > (b_file->size << 3) ||
605 4 3 if (!cache[a_idx]) {
606 0 4 if ((error = similarity_sig(&a_info, opts, cache)) < 0)
609 7 0 if (!cache[b_idx]) {
610 0 7 if ((error = similarity_sig(&b_info, opts, cache)) < 0)
617 7 0 if (cache[a_idx] && cache[b_idx])
7 0 if (cache[a_idx] && cache[b_idx])
635 0 0 git_diff_delta *delta = GIT_VECTOR_GET(&diff->deltas, delta_idx);
637 0 0 if ((delta->flags & GIT_DIFF_FLAG__HAS_SELF_SIMILARITY) != 0)
642 0 0 if (error < 0)
645 0 0 if (similarity >= 0) {
659 25 0 git_diff_delta *delta = GIT_VECTOR_GET(&diff->deltas, delta_idx);
662 10 15 if (!GIT_MODE_ISBLOB(delta->new_file.mode))
676 2 0 if (!FLAG_SET(opts, GIT_DIFF_FIND_REWRITES) &&
2 0 if (!FLAG_SET(opts, GIT_DIFF_FIND_REWRITES) &&
680 0 0 if (calc_self_similarity(diff, opts, delta_idx, cache) < 0)
683 0 0 if (FLAG_SET(opts, GIT_DIFF_BREAK_REWRITES) &&
0 0 if (FLAG_SET(opts, GIT_DIFF_BREAK_REWRITES) &&
688 0 0 if (FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES) &&
0 0 if (FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES) &&
697 0 7 if (!FLAG_SET(opts, GIT_DIFF_FIND_FOR_UNTRACKED))
715 25 0 git_diff_delta *delta = GIT_VECTOR_GET(&diff->deltas, delta_idx);
718 16 9 if (!GIT_MODE_ISBLOB(delta->old_file.mode))
734 0 0 if (!FLAG_SET(opts, GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED))
736 0 0 if (FLAG_SET(opts, GIT_DIFF_FIND_REMOVE_UNMODIFIED))
742 0 2 if (FLAG_SET(opts, GIT_DIFF_FIND_COPIES))
746 2 0 if (!FLAG_SET(opts, GIT_DIFF_FIND_REWRITES) &&
2 0 if (!FLAG_SET(opts, GIT_DIFF_FIND_REWRITES) &&
750 0 0 if (calc_self_similarity(diff, opts, delta_idx, cache) < 0)
753 0 0 if (FLAG_SET(opts, GIT_DIFF_BREAK_REWRITES) &&
0 0 if (FLAG_SET(opts, GIT_DIFF_BREAK_REWRITES) &&
759 0 0 if (FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES) &&
0 0 if (FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES) &&
772 0 0 return (delta->status == GIT_DELTA_TYPECHANGE ||
0 0 return (delta->status == GIT_DELTA_TYPECHANGE ||
778 0 1 return (delta->status == GIT_DELTA_ADDED ||
779 0 0 delta->status == GIT_DELTA_UNTRACKED ||
780 1 5 delta->status == GIT_DELTA_UNREADABLE ||
0 0 delta->status == GIT_DELTA_UNREADABLE ||
819 0 11 assert(diff);
821 0 11 if ((error = normalize_find_opts(diff, &opts, given_opts)) < 0)
827 11 0 if (!num_deltas || !git__is_uint32(num_deltas))
11 0 if (!num_deltas || !git__is_uint32(num_deltas))
831 0 11 if ((opts.flags & GIT_DIFF_FIND_ALL) == 0)
834 0 11 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&sigcache_size, num_deltas, 2);
0 11 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&sigcache_size, num_deltas, 2);
836 0 11 GIT_ERROR_CHECK_ALLOC(sigcache);
843 25 11 git_vector_foreach(&diff->deltas, t, tgt) {
844 7 18 if (is_rename_source(diff, &opts, t, sigcache))
847 13 12 if (is_rename_target(diff, &opts, t, sigcache))
850 0 25 if ((tgt->flags & GIT_DIFF_FLAG__TO_SPLIT) != 0)
855 7 4 if (!num_srcs || !num_tgts)
7 0 if (!num_srcs || !num_tgts)
859 0 7 GIT_ERROR_CHECK_ALLOC(src2tgt);
861 0 7 GIT_ERROR_CHECK_ALLOC(tgt2src);
863 0 7 if (FLAG_SET(&opts, GIT_DIFF_FIND_COPIES)) {
865 0 0 GIT_ERROR_CHECK_ALLOC(tgt2src_copy);
875 17 0 git_vector_foreach(&diff->deltas, t, tgt) {
877 7 10 if ((tgt->flags & GIT_DIFF_FLAG__IS_RENAME_TARGET) == 0)
882 17 0 git_vector_foreach(&diff->deltas, s, src) {
884 7 10 if ((src->flags & GIT_DIFF_FLAG__IS_RENAME_SOURCE) == 0)
888 0 10 if (s == t)
890 0 10 else if ((error = similarity_measure(
894 0 10 if (result < 0)
899 6 4 if (tgt2src[t].similarity < similarity &&
6 0 if (tgt2src[t].similarity < similarity &&
903 0 6 if (src2tgt[s].similarity > 0) {
907 0 6 if (tgt2src[t].similarity > 0) {
920 0 10 if (tgt2src_copy != NULL &&
0 0 if (tgt2src_copy != NULL &&
927 10 0 if (++tried_srcs >= num_srcs)
931 0 0 if (tried_srcs > opts.rename_limit)
935 7 3 if (++tried_tgts >= num_tgts)
939 0 7 if (num_bumped > 0) /* try again if we bumped some items */
946 19 7 git_vector_foreach(&diff->deltas, t, tgt) {
948 9 10 if ((tgt->flags & GIT_DIFF_FLAG__IS_RENAME_TARGET) == 0)
952 6 4 if (tgt2src[t].similarity)
954 0 4 else if (tgt2src_copy && tgt2src_copy[t].similarity)
0 0 else if (tgt2src_copy && tgt2src_copy[t].similarity)
960 6 0 src = GIT_VECTOR_GET(&diff->deltas, s);
970 6 0 if (src->status == GIT_DELTA_DELETED) {
972 6 0 if (delta_is_new_only(tgt)) {
974 0 6 if (best_match->similarity < opts.rename_threshold)
982 0 0 assert(delta_is_split(tgt));
984 0 0 if (best_match->similarity < opts.rename_from_rewrite_threshold)
992 0 0 assert(src->status == GIT_DELTA_DELETED);
1000 0 0 if (src2tgt[t].similarity > 0 && src2tgt[t].idx > t) {
0 0 if (src2tgt[t].similarity > 0 && src2tgt[t].idx > t) {
1007 0 0 else if (delta_is_split(src)) {
1009 0 0 if (delta_is_new_only(tgt)) {
1011 0 0 if (best_match->similarity < opts.rename_threshold)
1016 0 0 src->status = (diff->new_src == GIT_ITERATOR_WORKDIR) ?
1028 0 0 assert(delta_is_split(src));
1030 0 0 if (best_match->similarity < opts.rename_from_rewrite_threshold)
1044 0 0 if (tgt2src[s].idx == t &&
0 0 if (tgt2src[s].idx == t &&
1054 0 0 else if (src2tgt[t].similarity > 0 && src2tgt[t].idx > t) {
0 0 else if (src2tgt[t].similarity > 0 && src2tgt[t].idx > t) {
1063 0 0 else if (FLAG_SET(&opts, GIT_DIFF_FIND_COPIES)) {
1064 0 0 if (tgt2src_copy[t].similarity < opts.copy_threshold)
1069 0 0 src = GIT_VECTOR_GET(&diff->deltas, best_match->idx);
1071 0 0 if (delta_is_split(tgt)) {
1073 0 0 if (error < 0)
1078 0 0 if (!delta_is_split(tgt) && !delta_is_new_only(tgt))
0 0 if (!delta_is_split(tgt) && !delta_is_new_only(tgt))
1095 1 6 if (num_rewrites > 0 || num_updates > 0)
0 1 if (num_rewrites > 0 || num_updates > 0)
1098 1 5 FLAG_SET(&opts, GIT_DIFF_BREAK_REWRITES) &&
1 0 FLAG_SET(&opts, GIT_DIFF_BREAK_REWRITES) &&
1106 11 0 if (sigcache) {
1107 50 11 for (t = 0; t < num_deltas * 2; ++t) {
1108 11 39 if (sigcache[t] != NULL)
1114 11 0 if (!given_opts || !given_opts->metric)
11 0 if (!given_opts || !given_opts->metric)