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 |
GIT_ASSERT_WITH_RETVAL(b->status != GIT_DELTA_UNMODIFIED, NULL); |
95
|
0 |
3 |
if (dup->status == GIT_DELTA_DELETED) { |
96
|
0 |
0 |
if (a->status == GIT_DELTA_ADDED) { |
124
|
0 |
6 |
GIT_ASSERT_ARG(onto); |
125
|
0 |
6 |
GIT_ASSERT_ARG(from); |
127
|
2 |
4 |
if (!from->deltas.length) |
133
|
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) || |
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, diff->deltas._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->flags & GIT_DIFF_FLAG_VALID_SIZE) || |
|
0 |
4 |
if ((info->file->flags & GIT_DIFF_FLAG_VALID_SIZE) || |
479
|
5 |
6 |
if (info->src == GIT_ITERATOR_WORKDIR) { |
480
|
0 |
5 |
if ((error = git_repository_workdir_path( |
485
|
0 |
5 |
if (!git_fs_path_isfile(info->data.ptr)) |
497
|
0 |
6 |
if (info->odb_obj != NULL) |
504
|
0 |
6 |
if (error < 0) { |
511
|
0 |
6 |
if (file->size != git_blob_rawsize(info->blob)) |
514
|
6 |
0 |
sz = git__is_sizet(file->size) ? (size_t)file->size : (size_t)-1; |
527
|
0 |
14 |
if (info->odb_obj) |
530
|
6 |
8 |
if (info->blob) |
559
|
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)) |
563
|
0 |
10 |
if (exact_match) { |
564
|
0 |
0 |
if (git_oid_is_zero(&a_file->id) && |
|
0 |
0 |
if (git_oid_is_zero(&a_file->id) && |
565
|
0 |
0 |
diff->old_src == GIT_ITERATOR_WORKDIR && |
570
|
0 |
0 |
if (git_oid_is_zero(&b_file->id) && |
|
0 |
0 |
if (git_oid_is_zero(&b_file->id) && |
571
|
0 |
0 |
diff->new_src == GIT_ITERATOR_WORKDIR && |
578
|
3 |
7 |
if (git_oid__cmp(&a_file->id, &b_file->id) == 0) { |
584
|
0 |
7 |
if (exact_match) { |
593
|
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) |
595
|
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) |
599
|
0 |
7 |
if (a_file->size > 127 && |
|
0 |
0 |
if (a_file->size > 127 && |
600
|
0 |
0 |
b_file->size > 127 && |
601
|
0 |
0 |
(a_file->size > (b_file->size << 3) || |
606
|
4 |
3 |
if (!cache[a_idx]) { |
607
|
0 |
4 |
if ((error = similarity_sig(&a_info, opts, cache)) < 0) |
610
|
7 |
0 |
if (!cache[b_idx]) { |
611
|
0 |
7 |
if ((error = similarity_sig(&b_info, opts, cache)) < 0) |
618
|
7 |
0 |
if (cache[a_idx] && cache[b_idx]) |
|
7 |
0 |
if (cache[a_idx] && cache[b_idx]) |
636
|
0 |
0 |
git_diff_delta *delta = GIT_VECTOR_GET(&diff->deltas, delta_idx); |
638
|
0 |
0 |
if ((delta->flags & GIT_DIFF_FLAG__HAS_SELF_SIMILARITY) != 0) |
643
|
0 |
0 |
if (error < 0) |
646
|
0 |
0 |
if (similarity >= 0) { |
660
|
25 |
0 |
git_diff_delta *delta = GIT_VECTOR_GET(&diff->deltas, delta_idx); |
663
|
10 |
15 |
if (!GIT_MODE_ISBLOB(delta->new_file.mode)) |
677
|
2 |
0 |
if (!FLAG_SET(opts, GIT_DIFF_FIND_REWRITES) && |
|
2 |
0 |
if (!FLAG_SET(opts, GIT_DIFF_FIND_REWRITES) && |
681
|
0 |
0 |
if (calc_self_similarity(diff, opts, delta_idx, cache) < 0) |
684
|
0 |
0 |
if (FLAG_SET(opts, GIT_DIFF_BREAK_REWRITES) && |
|
0 |
0 |
if (FLAG_SET(opts, GIT_DIFF_BREAK_REWRITES) && |
689
|
0 |
0 |
if (FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES) && |
|
0 |
0 |
if (FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES) && |
698
|
0 |
7 |
if (!FLAG_SET(opts, GIT_DIFF_FIND_FOR_UNTRACKED)) |
716
|
25 |
0 |
git_diff_delta *delta = GIT_VECTOR_GET(&diff->deltas, delta_idx); |
719
|
16 |
9 |
if (!GIT_MODE_ISBLOB(delta->old_file.mode)) |
735
|
0 |
0 |
if (!FLAG_SET(opts, GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED)) |
737
|
0 |
0 |
if (FLAG_SET(opts, GIT_DIFF_FIND_REMOVE_UNMODIFIED)) |
743
|
0 |
2 |
if (FLAG_SET(opts, GIT_DIFF_FIND_COPIES)) |
747
|
2 |
0 |
if (!FLAG_SET(opts, GIT_DIFF_FIND_REWRITES) && |
|
2 |
0 |
if (!FLAG_SET(opts, GIT_DIFF_FIND_REWRITES) && |
751
|
0 |
0 |
if (calc_self_similarity(diff, opts, delta_idx, cache) < 0) |
754
|
0 |
0 |
if (FLAG_SET(opts, GIT_DIFF_BREAK_REWRITES) && |
|
0 |
0 |
if (FLAG_SET(opts, GIT_DIFF_BREAK_REWRITES) && |
760
|
0 |
0 |
if (FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES) && |
|
0 |
0 |
if (FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES) && |
773
|
0 |
0 |
return (delta->status == GIT_DELTA_TYPECHANGE || |
|
0 |
0 |
return (delta->status == GIT_DELTA_TYPECHANGE || |
779
|
0 |
1 |
return (delta->status == GIT_DELTA_ADDED || |
780
|
0 |
0 |
delta->status == GIT_DELTA_UNTRACKED || |
781
|
1 |
5 |
delta->status == GIT_DELTA_UNREADABLE || |
|
0 |
0 |
delta->status == GIT_DELTA_UNREADABLE || |
820
|
0 |
11 |
GIT_ASSERT_ARG(diff); |
822
|
0 |
11 |
if ((error = normalize_find_opts(diff, &opts, given_opts)) < 0) |
828
|
11 |
0 |
if (!num_deltas || !git__is_uint32(num_deltas)) |
|
11 |
0 |
if (!num_deltas || !git__is_uint32(num_deltas)) |
832
|
0 |
11 |
if ((opts.flags & GIT_DIFF_FIND_ALL) == 0) |
835
|
0 |
11 |
GIT_ERROR_CHECK_ALLOC_MULTIPLY(&sigcache_size, num_deltas, 2); |
|
0 |
11 |
GIT_ERROR_CHECK_ALLOC_MULTIPLY(&sigcache_size, num_deltas, 2); |
837
|
0 |
11 |
GIT_ERROR_CHECK_ALLOC(sigcache); |
844
|
25 |
11 |
git_vector_foreach(&diff->deltas, t, tgt) { |
845
|
7 |
18 |
if (is_rename_source(diff, &opts, t, sigcache)) |
848
|
13 |
12 |
if (is_rename_target(diff, &opts, t, sigcache)) |
851
|
0 |
25 |
if ((tgt->flags & GIT_DIFF_FLAG__TO_SPLIT) != 0) |
856
|
7 |
4 |
if (!num_srcs || !num_tgts) |
|
7 |
0 |
if (!num_srcs || !num_tgts) |
860
|
0 |
7 |
GIT_ERROR_CHECK_ALLOC(src2tgt); |
862
|
0 |
7 |
GIT_ERROR_CHECK_ALLOC(tgt2src); |
864
|
0 |
7 |
if (FLAG_SET(&opts, GIT_DIFF_FIND_COPIES)) { |
866
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(tgt2src_copy); |
876
|
17 |
0 |
git_vector_foreach(&diff->deltas, t, tgt) { |
878
|
7 |
10 |
if ((tgt->flags & GIT_DIFF_FLAG__IS_RENAME_TARGET) == 0) |
883
|
17 |
0 |
git_vector_foreach(&diff->deltas, s, src) { |
885
|
7 |
10 |
if ((src->flags & GIT_DIFF_FLAG__IS_RENAME_SOURCE) == 0) |
889
|
0 |
10 |
if (s == t) |
891
|
0 |
10 |
else if ((error = similarity_measure( |
895
|
0 |
10 |
if (result < 0) |
900
|
6 |
4 |
if (tgt2src[t].similarity < similarity && |
|
6 |
0 |
if (tgt2src[t].similarity < similarity && |
904
|
0 |
6 |
if (src2tgt[s].similarity > 0) { |
908
|
0 |
6 |
if (tgt2src[t].similarity > 0) { |
921
|
0 |
10 |
if (tgt2src_copy != NULL && |
|
0 |
0 |
if (tgt2src_copy != NULL && |
928
|
10 |
0 |
if (++tried_srcs >= num_srcs) |
932
|
0 |
0 |
if (tried_srcs > opts.rename_limit) |
936
|
7 |
3 |
if (++tried_tgts >= num_tgts) |
940
|
0 |
7 |
if (num_bumped > 0) /* try again if we bumped some items */ |
947
|
19 |
7 |
git_vector_foreach(&diff->deltas, t, tgt) { |
949
|
9 |
10 |
if ((tgt->flags & GIT_DIFF_FLAG__IS_RENAME_TARGET) == 0) |
953
|
6 |
4 |
if (tgt2src[t].similarity) |
955
|
0 |
4 |
else if (tgt2src_copy && tgt2src_copy[t].similarity) |
|
0 |
0 |
else if (tgt2src_copy && tgt2src_copy[t].similarity) |
961
|
6 |
0 |
src = GIT_VECTOR_GET(&diff->deltas, s); |
971
|
6 |
0 |
if (src->status == GIT_DELTA_DELETED) { |
973
|
6 |
0 |
if (delta_is_new_only(tgt)) { |
975
|
0 |
6 |
if (best_match->similarity < opts.rename_threshold) |
983
|
0 |
0 |
GIT_ASSERT(delta_is_split(tgt)); |
985
|
0 |
0 |
if (best_match->similarity < opts.rename_from_rewrite_threshold) |
993
|
0 |
0 |
GIT_ASSERT(src->status == GIT_DELTA_DELETED); |
1001
|
0 |
0 |
if (src2tgt[t].similarity > 0 && src2tgt[t].idx > t) { |
|
0 |
0 |
if (src2tgt[t].similarity > 0 && src2tgt[t].idx > t) { |
1008
|
0 |
0 |
else if (delta_is_split(src)) { |
1010
|
0 |
0 |
if (delta_is_new_only(tgt)) { |
1012
|
0 |
0 |
if (best_match->similarity < opts.rename_threshold) |
1017
|
0 |
0 |
src->status = (diff->new_src == GIT_ITERATOR_WORKDIR) ? |
1029
|
0 |
0 |
GIT_ASSERT(delta_is_split(src)); |
1031
|
0 |
0 |
if (best_match->similarity < opts.rename_from_rewrite_threshold) |
1045
|
0 |
0 |
if (tgt2src[s].idx == t && |
|
0 |
0 |
if (tgt2src[s].idx == t && |
1055
|
0 |
0 |
else if (src2tgt[t].similarity > 0 && src2tgt[t].idx > t) { |
|
0 |
0 |
else if (src2tgt[t].similarity > 0 && src2tgt[t].idx > t) { |
1064
|
0 |
0 |
else if (FLAG_SET(&opts, GIT_DIFF_FIND_COPIES)) { |
1065
|
0 |
0 |
if (tgt2src_copy[t].similarity < opts.copy_threshold) |
1070
|
0 |
0 |
src = GIT_VECTOR_GET(&diff->deltas, best_match->idx); |
1072
|
0 |
0 |
if (delta_is_split(tgt)) { |
1074
|
0 |
0 |
if (error < 0) |
1079
|
0 |
0 |
if (!delta_is_split(tgt) && !delta_is_new_only(tgt)) |
|
0 |
0 |
if (!delta_is_split(tgt) && !delta_is_new_only(tgt)) |
1096
|
1 |
6 |
if (num_rewrites > 0 || num_updates > 0) |
|
0 |
1 |
if (num_rewrites > 0 || num_updates > 0) |
1099
|
1 |
5 |
FLAG_SET(&opts, GIT_DIFF_BREAK_REWRITES) && |
|
1 |
0 |
FLAG_SET(&opts, GIT_DIFF_BREAK_REWRITES) && |
1107
|
11 |
0 |
if (sigcache) { |
1108
|
50 |
11 |
for (t = 0; t < num_deltas * 2; ++t) { |
1109
|
11 |
39 |
if (sigcache[t] != NULL) |
1115
|
11 |
0 |
if (!given_opts || !given_opts->metric) |
|
11 |
0 |
if (!given_opts || !given_opts->metric) |