Branch Coverage

deps/libgit2/src/merge.c
Criterion Covered Total %
branch 586 1308 44.8


line true false branch
92 0 19 if (length < 2) {
97 0 19 if (git_vector_init(&list, length - 1, NULL) < 0)
100 0 19 if (git_revwalk_new(&walk, repo) < 0)
103 19 19 for (i = 1; i < length; i++) {
105 0 19 if (commit == NULL)
112 0 19 if (commit == NULL)
115 0 19 if (git_merge__bases_many(&result, walk, commit, &list) < 0)
118 0 19 if (!result) {
142 13 0 assert(out && repo && input_array);
13 0 assert(out && repo && input_array);
0 13 assert(out && repo && input_array);
144 0 13 if ((error = merge_bases_many(&result, &walk, repo, length, input_array)) < 0)
162 6 0 assert(out && repo && input_array);
6 0 assert(out && repo && input_array);
0 6 assert(out && repo && input_array);
164 0 6 if ((error = merge_bases_many(&result, &walk, repo, length, input_array)) < 0)
170 6 6 while (list) {
171 6 0 git_oid *id = git_array_alloc(array);
0 0 git_oid *id = git_array_alloc(array);
172 0 6 if (id == NULL) {
196 0 0 assert(out && repo && input_array);
0 0 assert(out && repo && input_array);
0 0 assert(out && repo && input_array);
198 0 0 if (length < 2) {
204 0 0 for (i = 1; i < length; i++) {
206 0 0 if (error < 0)
223 0 21 if (git_revwalk_new(&walk, repo) < 0)
227 0 21 if (commit == NULL)
237 0 21 if (commit == NULL)
240 1 20 if (git_merge__bases_many(&result, walk, commit, &list) < 0)
243 0 20 if (!result) {
266 1 20 if ((error = merge_bases(&result, &walk, repo, one, two)) < 0)
285 0 0 if ((error = merge_bases(&result, &walk, repo, one, two)) < 0)
289 0 0 while (list) {
290 0 0 git_oid *id = git_array_alloc(array);
0 0 git_oid *id = git_array_alloc(array);
291 0 0 if (id == NULL)
314 164 39 for (i = 0; i < git_pqueue_size(list); i++) {
316 155 9 if ((commit->flags & STALE) == 0)
326 0 0 while (commit) {
329 0 0 if (!(mark & commit->flags))
334 0 0 for (i = 1; i < commit->out_degree; i++) {
336 0 0 if (git_commit_list_insert(p, plist) == NULL)
340 0 0 commit = commit->out_degree ? commit->parents[0] : NULL;
352 0 0 git_vector_foreach(commits, i, c) {
353 0 0 if (git_commit_list_insert(c, &list) == NULL)
357 0 0 while (list)
358 0 0 if (clear_commit_marks_1(&list, git_commit_list_pop(&list), mark) < 0)
366 0 0 if (git_commit_list_insert(commit, &list) == NULL)
368 0 0 while (list)
369 0 0 if (clear_commit_marks_1(&list, git_commit_list_pop(&list), mark) < 0)
384 0 39 if (git_pqueue_init(&list, 0, twos->length * 2, git_commit_list_time_cmp) < 0)
388 0 39 if (git_pqueue_insert(&list, one) < 0)
391 39 39 git_vector_foreach(twos, i, two) {
392 0 39 if (git_commit_list_parse(walk, two) < 0)
397 0 39 if (git_pqueue_insert(&list, two) < 0)
402 155 39 while (interesting(&list)) {
406 0 155 if (commit == NULL)
410 66 89 if (flags == (PARENT1 | PARENT2)) {
411 39 27 if (!(commit->flags & RESULT)) {
413 0 39 if (git_commit_list_insert(commit, &result) == NULL)
420 97 155 for (i = 0; i < commit->out_degree; i++) {
422 16 81 if ((p->flags & flags) == flags)
425 0 81 if ((error = git_commit_list_parse(walk, p)) < 0)
429 0 81 if (git_pqueue_insert(&list, p) < 0)
448 0 0 GIT_ERROR_CHECK_ALLOC(redundant);
450 0 0 GIT_ERROR_CHECK_ALLOC(filled_index);
452 0 0 for (i = 0; i < commits->length; ++i) {
453 0 0 if ((error = git_commit_list_parse(walk, commits->contents[i])) < 0)
457 0 0 for (i = 0; i < commits->length; ++i) {
461 0 0 if (redundant[i])
466 0 0 for (j = 0; j < commits->length; j++) {
467 0 0 if (i == j || redundant[j])
0 0 if (i == j || redundant[j])
471 0 0 if ((error = git_vector_insert(&work, commits->contents[j])) < 0)
476 0 0 if (error < 0)
479 0 0 if (commit->flags & PARENT2)
482 0 0 for (j = 0; j < work.length; j++) {
484 0 0 if (w->flags & PARENT1)
490 0 0 if ((error = clear_commit_marks(commit, ALL_FLAGS)) < 0 ||
0 0 if ((error = clear_commit_marks(commit, ALL_FLAGS)) < 0 ||
495 0 0 for (i = 0; i < commits->length; ++i) {
496 0 0 if (redundant[i])
515 0 40 if (twos->length == 0) {
521 40 40 git_vector_foreach(twos, i, two) {
522 0 40 if (one == two)
523 0 0 return git_commit_list_insert(one, out) ? 0 : -1;
526 1 39 if (git_commit_list_parse(walk, one) < 0)
530 0 39 if (error < 0)
537 39 39 while (tmp) {
539 39 0 if (!(c->flags & STALE))
540 0 39 if (git_commit_list_insert_by_date(c, &result) == NULL)
548 39 0 if (result && result->next) {
0 39 if (result && result->next) {
551 0 0 while (result)
554 0 0 if ((error = clear_commit_marks(one, ALL_FLAGS)) < 0 ||
0 0 if ((error = clear_commit_marks(one, ALL_FLAGS)) < 0 ||
555 0 0 (error = clear_commit_marks_many(twos, ALL_FLAGS)) < 0 ||
561 0 0 git_vector_foreach(&redundant, i, two) {
562 0 0 if (two != NULL)
584 0 0 assert(repo && cb);
0 0 assert(repo && cb);
586 0 0 if ((error = git_buf_joinpath(&merge_head_path, repo->gitdir,
590 0 0 if ((error = git_futils_readbuffer(&merge_head_file,
596 0 0 while ((line = git__strsep(&buffer, "\n")) != NULL) {
597 0 0 if (strlen(line) != GIT_OID_HEXSZ) {
603 0 0 if ((error = git_oid_fromstr(&oid, line)) < 0)
606 0 0 if ((error = cb(&oid, payload)) != 0) {
614 0 0 if (*buffer) {
631 1 88 if (a->path == NULL)
634 88 0 if ((value = a->mode - b->mode) == 0 &&
64 24 if ((value = a->mode - b->mode) == 0 &&
653 22 0 assert(resolved && diff_list && conflict);
22 0 assert(resolved && diff_list && conflict);
0 22 assert(resolved && diff_list && conflict);
657 22 0 if (conflict->type == GIT_MERGE_DIFF_DIRECTORY_FILE ||
0 22 if (conflict->type == GIT_MERGE_DIFF_DIRECTORY_FILE ||
661 22 0 if (conflict->our_status == GIT_DELTA_RENAMED ||
0 22 if (conflict->our_status == GIT_DELTA_RENAMED ||
670 8 14 ours_theirs_differ = ours_changed && theirs_changed &&
697 8 14 if (ours_changed && !ours_empty && !ours_theirs_differ)
7 1 if (ours_changed && !ours_empty && !ours_theirs_differ)
1 6 if (ours_changed && !ours_empty && !ours_theirs_differ)
700 7 14 else if (ours_changed && ours_empty && theirs_empty)
1 6 else if (ours_changed && ours_empty && theirs_empty)
0 1 else if (ours_changed && ours_empty && theirs_empty)
703 4 17 else if (ours_empty && !theirs_changed)
0 4 else if (ours_empty && !theirs_changed)
706 14 7 else if (!ours_changed && theirs_empty)
0 14 else if (!ours_changed && theirs_empty)
709 7 14 else if (ours_changed && !theirs_changed)
0 7 else if (ours_changed && !theirs_changed)
712 14 7 else if (!ours_changed && theirs_changed)
14 0 else if (!ours_changed && theirs_changed)
717 15 7 if (result != NULL &&
15 0 if (result != NULL &&
718 15 0 GIT_MERGE_INDEX_ENTRY_EXISTS(*result) &&
736 7 0 assert(resolved && diff_list && conflict);
7 0 assert(resolved && diff_list && conflict);
0 7 assert(resolved && diff_list && conflict);
740 7 0 if (conflict->type == GIT_MERGE_DIFF_DIRECTORY_FILE ||
0 7 if (conflict->type == GIT_MERGE_DIFF_DIRECTORY_FILE ||
751 7 0 if (ours_changed && ours_empty && theirs_empty)
1 6 if (ours_changed && ours_empty && theirs_empty)
0 1 if (ours_changed && ours_empty && theirs_empty)
754 1 6 else if (ours_empty && !theirs_changed)
0 1 else if (ours_empty && !theirs_changed)
757 0 7 else if (!ours_changed && theirs_empty)
0 0 else if (!ours_changed && theirs_empty)
760 0 7 if (*resolved)
776 7 0 assert(resolved && diff_list && conflict);
7 0 assert(resolved && diff_list && conflict);
0 7 assert(resolved && diff_list && conflict);
780 6 1 if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ||
0 6 if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ||
787 6 0 if (!ours_renamed && !theirs_renamed)
6 0 if (!ours_renamed && !theirs_renamed)
791 0 0 if (conflict->type == GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1 ||
0 0 if (conflict->type == GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1 ||
792 0 0 conflict->type == GIT_MERGE_DIFF_BOTH_RENAMED_1_TO_2 ||
800 0 0 if (ours_changed && theirs_changed &&
804 0 0 if ((merged = git_pool_malloc(&diff_list->pool, sizeof(git_index_entry))) == NULL)
807 0 0 if (ours_changed)
812 0 0 if (ours_renamed)
828 6 1 if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ||
0 6 if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) ||
833 0 6 if (conflict->type == GIT_MERGE_DIFF_DIRECTORY_FILE)
837 6 0 if (S_ISGITLINK(conflict->ancestor_entry.mode) ||
6 0 if (S_ISGITLINK(conflict->ancestor_entry.mode) ||
838 0 6 S_ISGITLINK(conflict->our_entry.mode) ||
843 6 0 if ((S_ISLNK(conflict->ancestor_entry.mode) ^
844 0 6 S_ISLNK(conflict->our_entry.mode)) ||
850 6 0 if (conflict->type == GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1 ||
0 6 if (conflict->type == GIT_MERGE_DIFF_BOTH_RENAMED_2_TO_1 ||
854 0 6 if ((conflict->our_status & GIT_DELTA_RENAMED) == GIT_DELTA_RENAMED &&
0 0 if ((conflict->our_status & GIT_DELTA_RENAMED) == GIT_DELTA_RENAMED &&
855 0 0 (conflict->their_status & GIT_DELTA_RENAMED) == GIT_DELTA_RENAMED &&
879 2 4 if ((error = driver->apply(driver, &path, &mode, &buf, name, src)) < 0 ||
2 0 if ((error = driver->apply(driver, &path, &mode, &buf, name, src)) < 0 ||
880 2 0 (error = git_repository_odb(&odb, src->repo)) < 0 ||
885 0 2 GIT_ERROR_CHECK_ALLOC(result);
892 0 2 GIT_ERROR_CHECK_ALLOC(result->path);
920 7 0 assert(resolved && diff_list && conflict);
7 0 assert(resolved && diff_list && conflict);
0 7 assert(resolved && diff_list && conflict);
924 1 6 if (!merge_conflict_can_resolve_contents(conflict))
931 6 0 &conflict->ancestor_entry : NULL;
933 6 0 &conflict->our_entry : NULL;
935 6 0 &conflict->their_entry : NULL;
937 2 4 if (file_opts->favor != GIT_MERGE_FILE_FAVOR_NORMAL) {
949 0 4 if ((error = git_merge_driver_for_source(&name, &driver, &source)) < 0)
952 0 4 if (driver == NULL)
956 6 0 if (driver) {
960 0 6 if (error == GIT_PASSTHROUGH)
964 0 6 if (fallback) {
969 4 2 if (error < 0) {
970 4 0 if (error == GIT_EMERGECONFLICT)
1000 0 22 if ((error = merge_conflict_resolve_trivial(
1004 7 15 if (!resolved && (error = merge_conflict_resolve_one_removed(
0 7 if (!resolved && (error = merge_conflict_resolve_one_removed(
1008 7 15 if (!resolved && (error = merge_conflict_resolve_one_renamed(
0 7 if (!resolved && (error = merge_conflict_resolve_one_renamed(
1012 7 15 if (!resolved && (error = merge_conflict_resolve_contents(
0 7 if (!resolved && (error = merge_conflict_resolve_contents(
1040 0 0 if (*out || *out == &cache_invalid_marker)
0 0 if (*out || *out == &cache_invalid_marker)
1045 0 0 if ((error = git_blob_lookup(&blob, repo, &entry->id)) < 0)
1057 0 0 if (!git__is_sizet(blobsize))
1063 0 0 if (error == GIT_EBUFS)
1083 0 0 if (!GIT_MODE_ISBLOB(a->mode) || !GIT_MODE_ISBLOB(b->mode))
0 0 if (!GIT_MODE_ISBLOB(a->mode) || !GIT_MODE_ISBLOB(b->mode))
1087 0 0 if ((error = index_entry_similarity_calc(&cache[a_idx], repo, a, opts)) < 0 ||
0 0 if ((error = index_entry_similarity_calc(&cache[a_idx], repo, a, opts)) < 0 ||
1092 0 0 if (cache[a_idx] == &cache_invalid_marker || cache[b_idx] == &cache_invalid_marker)
0 0 if (cache[a_idx] == &cache_invalid_marker || cache[b_idx] == &cache_invalid_marker)
1096 0 0 if (opts->metric->similarity(&score, cache[a_idx], cache[b_idx], opts->metric->payload) < 0)
1100 0 0 if (score < 0)
1102 0 0 else if (score > 100)
1120 0 44 if (!map)
1123 1 44 git_oidmap_foreach_value(map, queue, {
1134 1 0 if ((queue = git_oidmap_get(map, id)) == NULL) {
1136 0 1 GIT_ERROR_CHECK_ALLOC(queue);
1142 0 1 if (git_oidmap_set(map, id, queue) < 0)
1145 0 0 array_entry = git_array_alloc(queue->arr);
0 0 array_entry = git_array_alloc(queue->arr);
1146 0 0 GIT_ERROR_CHECK_ALLOC(array_entry);
1158 3 0 if ((queue = git_oidmap_get(map, id)) == NULL)
1161 0 0 if (queue->next_pos == 0) {
1164 0 0 array_entry = git_array_get(queue->arr, queue->next_pos - 1);
1165 0 0 if (array_entry == NULL)
1192 22 22 git_vector_foreach(&diff_list->conflicts, i, conflict_src) {
1195 3 19 if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->ancestor_entry))
1198 1 18 if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->our_entry)) {
1200 0 1 if (error < 0)
1204 0 19 if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->their_entry)) {
1206 0 0 if (error < 0)
1211 22 22 git_vector_foreach(&diff_list->conflicts, j, conflict_tgt) {
1212 19 3 if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->ancestor_entry))
1215 0 3 if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->our_entry)) {
1216 0 0 if (deletes_by_oid_dequeue(&i, ours_deletes_by_oid, &conflict_tgt->our_entry.id) == 0) {
1225 3 0 if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->their_entry)) {
1226 0 3 if (deletes_by_oid_dequeue(&i, theirs_deletes_by_oid, &conflict_tgt->their_entry.id) == 0) {
1255 22 22 git_vector_foreach(&diff_list->conflicts, i, conflict_src) {
1258 19 3 if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->ancestor_entry) ||
18 1 if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->ancestor_entry) ||
1259 18 0 (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->our_entry) &&
1263 1 1 git_vector_foreach(&diff_list->conflicts, j, conflict_tgt) {
1267 1 0 if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->ancestor_entry))
1270 0 0 if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->our_entry) &&
0 0 if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->our_entry) &&
1274 0 0 if (similarity == GIT_EBUFS)
1276 0 0 else if (similarity < 0)
1279 0 0 if (similarity > similarity_ours[i].similarity &&
0 0 if (similarity > similarity_ours[i].similarity &&
1282 0 0 if (similarity_ours[i].similarity > 0)
1285 0 0 if (similarity_ours[j].similarity > 0)
1296 0 0 if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->their_entry) &&
0 0 if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->their_entry) &&
1300 0 0 if (similarity > similarity_theirs[i].similarity &&
0 0 if (similarity > similarity_theirs[i].similarity &&
1303 0 0 if (similarity_theirs[i].similarity > 0)
1306 0 0 if (similarity_theirs[j].similarity > 0)
1354 0 22 if (ours_renamed)
1357 0 22 if (theirs_renamed)
1361 0 22 if (ours_renamed && theirs_renamed) {
0 0 if (ours_renamed && theirs_renamed) {
1363 0 0 if (ours_source_idx == theirs_source_idx)
1369 0 22 } else if (ours_renamed) {
1371 0 0 if (similarity_theirs[ours_source_idx].similarity >= opts->rename_threshold)
1374 0 0 else if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->their_entry)) {
1379 0 0 else if (!GIT_MERGE_INDEX_ENTRY_EXISTS(ours_source->their_entry))
1382 0 0 else if (ours_source->type == GIT_MERGE_DIFF_MODIFIED_DELETED)
1384 0 22 } else if (theirs_renamed) {
1386 0 0 if (similarity_ours[theirs_source_idx].similarity >= opts->rename_threshold)
1389 0 0 else if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->our_entry)) {
1394 0 0 else if (!GIT_MERGE_INDEX_ENTRY_EXISTS(theirs_source->our_entry))
1397 0 0 else if (theirs_source->type == GIT_MERGE_DIFF_MODIFIED_DELETED)
1427 22 22 for (i = 0; i < diff_list->conflicts.length; i++) {
1433 18 4 if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->our_entry) &&
0 18 if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->our_entry) &&
1452 22 0 if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->their_entry) &&
0 22 if (GIT_MERGE_INDEX_ENTRY_EXISTS(target->their_entry) &&
1483 3 0 return (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry) &&
1484 3 19 !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) &&
0 3 !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry) &&
1499 22 22 git_vector_foreach(&diff_list->conflicts, i, entry) {
1500 19 3 if (GIT_MERGE_INDEX_ENTRY_EXISTS(entry->ancestor_entry) &&
18 1 if (GIT_MERGE_INDEX_ENTRY_EXISTS(entry->ancestor_entry) &&
1501 0 18 (!GIT_MERGE_INDEX_ENTRY_EXISTS(entry->our_entry) ||
1504 3 18 else if (!GIT_MERGE_INDEX_ENTRY_EXISTS(entry->ancestor_entry))
1520 22 0 assert(diff_list && opts);
0 22 assert(diff_list && opts);
1522 0 22 if ((opts->flags & GIT_MERGE_FIND_RENAMES) == 0)
1527 0 22 GIT_ERROR_CHECK_ALLOC(similarity_ours);
1531 0 22 GIT_ERROR_CHECK_ALLOC(similarity_theirs);
1536 0 22 if ((error = merge_diff_mark_similarity_exact(diff_list, similarity_ours, similarity_theirs)) < 0)
1539 22 0 if (opts->rename_threshold < 100 && diff_list->conflicts.length <= opts->target_limit) {
22 0 if (opts->rename_threshold < 100 && diff_list->conflicts.length <= opts->target_limit) {
1540 0 22 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&cache_size, diff_list->conflicts.length, 3);
0 22 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&cache_size, diff_list->conflicts.length, 3);
1542 0 22 GIT_ERROR_CHECK_ALLOC(cache);
1546 22 0 if (src_count > opts->target_limit || tgt_count > opts->target_limit) {
22 0 if (src_count > opts->target_limit || tgt_count > opts->target_limit) {
1549 0 22 if ((error = merge_diff_mark_similarity_inexact(
1564 22 0 if (cache != NULL) {
1565 66 22 for (i = 0; i < cache_size; ++i) {
1566 0 66 if (cache[i] != NULL && cache[i] != &cache_invalid_marker)
0 0 if (cache[i] != NULL && cache[i] != &cache_invalid_marker)
1584 19 3 if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry))
1586 0 3 else if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry))
1588 3 0 else if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry))
1597 0 0 if (conflict->our_status == GIT_DELTA_ADDED ||
0 0 if (conflict->our_status == GIT_DELTA_ADDED ||
1598 0 0 conflict->our_status == GIT_DELTA_MODIFIED ||
1599 0 0 conflict->their_status == GIT_DELTA_ADDED ||
1611 0 0 if (child_len < parent_len ||
0 0 if (child_len < parent_len ||
1628 0 22 else if(df_data->df_path)
1631 0 0 merge_diff_any_side_added_or_modified(df_data->prev_conflict) &&
1632 0 0 merge_diff_any_side_added_or_modified(conflict) &&
1651 0 22 if (conflict->our_status == GIT_DELTA_ADDED &&
0 0 if (conflict->our_status == GIT_DELTA_ADDED &&
1654 7 15 else if (conflict->our_status == GIT_DELTA_MODIFIED &&
7 0 else if (conflict->our_status == GIT_DELTA_MODIFIED &&
1657 1 14 else if (conflict->our_status == GIT_DELTA_DELETED &&
0 1 else if (conflict->our_status == GIT_DELTA_DELETED &&
1660 0 15 else if (conflict->our_status == GIT_DELTA_MODIFIED &&
0 0 else if (conflict->our_status == GIT_DELTA_MODIFIED &&
1663 1 14 else if (conflict->our_status == GIT_DELTA_DELETED &&
1 0 else if (conflict->our_status == GIT_DELTA_DELETED &&
1677 85 7 if (src != NULL) {
1679 0 85 if ((out->path = git_pool_strdup(pool, src->path)) == NULL)
1690 6 38 if (ancestor == NULL && other == NULL)
3 3 if (ancestor == NULL && other == NULL)
1692 3 38 else if (ancestor == NULL && other != NULL)
3 0 else if (ancestor == NULL && other != NULL)
1694 38 0 else if (ancestor != NULL && other == NULL)
1 37 else if (ancestor != NULL && other == NULL)
1696 0 37 else if (S_ISDIR(ancestor->mode) ^ S_ISDIR(other->mode))
1698 0 37 else if(S_ISLNK(ancestor->mode) ^ S_ISLNK(other->mode))
1700 11 26 else if (git_oid__cmp(&ancestor->id, &other->id) ||
0 11 else if (git_oid__cmp(&ancestor->id, &other->id) ||
1714 0 22 if ((conflict = git_pool_mallocz(pool, sizeof(git_merge_diff))) == NULL)
1718 0 22 index_entry_dup_pool(&conflict->our_entry, pool, entries[TREE_IDX_OURS]) < 0 ||
1740 22 0 merge_diff_detect_type(conflict) < 0 ||
1741 0 22 merge_diff_detect_df_conflict(merge_df_data, conflict) < 0 ||
1756 0 26 GIT_ERROR_CHECK_ALLOC(entry);
1758 26 0 if ((error = index_entry_dup_pool(entry, &diff_list->pool, tree_items[0])) >= 0)
1775 45 3 if (!entries[0] || !entries[1] || !entries[2]) {
44 1 if (!entries[0] || !entries[1] || !entries[2]) {
0 44 if (!entries[0] || !entries[1] || !entries[2]) {
1778 81 26 for (i = 1; i < 3; i++) {
1779 18 63 if (index_entry_cmp(entries[0], entries[i]) != 0) {
1788 22 26 find_data->diff_list, &find_data->df_data, entries) :
1808 0 22 if (diff_list == NULL)
1815 22 0 git_vector_init(&diff_list->staged, 0, NULL) < 0 ||
1816 0 22 git_vector_init(&diff_list->conflicts, 0, NULL) < 0 ||
1827 0 22 if (!diff_list)
1846 22 0 assert(repo && opts);
0 22 assert(repo && opts);
1848 0 22 if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
1851 18 4 if (given != NULL) {
1858 22 0 if ((opts->flags & GIT_MERGE_FIND_RENAMES) && !opts->rename_threshold)
21 1 if ((opts->flags & GIT_MERGE_FIND_RENAMES) && !opts->rename_threshold)
1861 18 4 if (given && given->default_driver) {
0 18 if (given && given->default_driver) {
1863 0 0 GIT_ERROR_CHECK_ALLOC(opts->default_driver);
1867 0 22 if (error == 0) {
1869 0 0 GIT_ERROR_CHECK_ALLOC(opts->default_driver);
1870 22 0 } else if (error == GIT_ENOTFOUND) {
1877 21 1 if (!opts->target_limit) {
1880 21 0 if (!limit)
1884 0 21 GIT_MERGE_DEFAULT_TARGET_LIMIT : (unsigned int)limit;
1888 22 0 if (!opts->metric) {
1890 0 22 GIT_ERROR_CHECK_ALLOC(opts->metric);
1915 0 6 if (!GIT_MERGE_INDEX_ENTRY_EXISTS(*entry))
1918 4 2 if ((reuc = git_index_reuc_get_bypath(index, entry->path)) != NULL) {
1919 12 4 for (i = 0; i < 3; i++) {
1940 2 22 git_vector_foreach(&diff_list->resolved, i, conflict) {
1943 2 0 &conflict->ancestor_entry : NULL;
1947 2 0 &conflict->our_entry : NULL;
1951 2 0 &conflict->their_entry : NULL;
1953 2 0 if (ancestor != NULL &&
0 2 if (ancestor != NULL &&
1957 2 0 if (ours != NULL &&
0 2 if (ours != NULL &&
1961 2 0 if (theirs != NULL &&
0 2 if (theirs != NULL &&
1979 0 22 if ((error = git_index_new(&index)) < 0)
1982 0 22 if ((error = git_index__fill(index, &diff_list->staged)) < 0)
1985 5 22 git_vector_foreach(&diff_list->conflicts, i, conflict) {
1988 5 0 &conflict->ancestor_entry : NULL;
1992 4 1 &conflict->our_entry : NULL;
1996 5 0 &conflict->their_entry : NULL;
1998 0 5 if ((error = git_index_conflict_add(index, ancestor, ours, theirs)) < 0)
2003 5 22 git_vector_foreach(&diff_list->conflicts, i, conflict) {
2006 0 5 if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry))
2013 4 1 conflict->our_entry.path : NULL;
2017 5 0 conflict->their_entry.path : NULL;
2019 4 1 if ((our_path && strcmp(ancestor_path, our_path) != 0) ||
4 0 if ((our_path && strcmp(ancestor_path, our_path) != 0) ||
5 0 if ((our_path && strcmp(ancestor_path, our_path) != 0) ||
2020 0 5 (their_path && strcmp(ancestor_path, their_path) != 0)) {
2021 0 0 if ((error = git_index_name_add(index, ancestor_path, our_path, their_path)) < 0)
2026 22 0 if (!skip_reuc) {
2027 0 22 if ((error = index_update_reuc(index, diff_list)) < 0)
2043 66 0 if (given)
2048 0 0 if (git_iterator_for_nothing(empty, &opts) < 0)
2073 22 0 assert(out && repo);
0 22 assert(out && repo);
2077 0 22 GIT_ERROR_CHECK_VERSION(
2080 0 22 if ((error = merge_normalize_opts(repo, &opts, given_opts)) < 0)
2087 0 22 if (opts.flags & GIT_MERGE__VIRTUAL_BASE) {
2096 0 22 GIT_ERROR_CHECK_ALLOC(diff_list);
2102 22 0 if ((error = git_merge_diff_list__find_differences(
2103 22 0 diff_list, ancestor_iter, our_iter, theirs_iter)) < 0 ||
2110 22 22 git_vector_foreach(&changes, i, conflict) {
2113 0 22 if ((error = merge_conflict_resolve(
2117 5 17 if (!resolved) {
2118 0 5 if ((opts.flags & GIT_MERGE_FAIL_ON_CONFLICT)) {
2132 18 4 if (!given_opts || !given_opts->metric)
18 0 if (!given_opts || !given_opts->metric)
2157 12 0 assert(out && repo);
0 12 assert(out && repo);
2160 12 0 if (ancestor_tree && merge_opts && (merge_opts->flags & GIT_MERGE_SKIP_REUC)) {
12 0 if (ancestor_tree && merge_opts && (merge_opts->flags & GIT_MERGE_SKIP_REUC)) {
0 12 if (ancestor_tree && merge_opts && (merge_opts->flags & GIT_MERGE_SKIP_REUC)) {
2164 0 0 if (our_tree && !git_oid_cmp(ancestor_tree_id, git_tree_id(our_tree)))
0 0 if (our_tree && !git_oid_cmp(ancestor_tree_id, git_tree_id(our_tree)))
2166 0 0 else if (their_tree && !git_oid_cmp(ancestor_tree_id, git_tree_id(their_tree)))
0 0 else if (their_tree && !git_oid_cmp(ancestor_tree_id, git_tree_id(their_tree)))
2169 0 0 if (result) {
2170 0 0 if ((error = git_index_new(out)) == 0)
2179 12 0 if ((error = git_iterator_for_tree(
2180 12 0 &ancestor_iter, (git_tree *)ancestor_tree, &iter_opts)) < 0 ||
2182 12 0 &our_iter, (git_tree *)our_tree, &iter_opts)) < 0 ||
2214 12 0 if (annotated_commit->type == GIT_ANNOTATED_COMMIT_REAL) {
2215 6 6 id = git_array_alloc(*ids);
6 0 id = git_array_alloc(*ids);
2216 0 12 GIT_ERROR_CHECK_ALLOC(id);
2220 0 0 for (i = 0; i < annotated_commit->parents.size; i++) {
2221 0 0 id = git_array_alloc(*ids);
0 0 id = git_array_alloc(*ids);
2222 0 0 GIT_ERROR_CHECK_ALLOC(id);
2246 0 0 if (opts)
2252 0 0 if ((merge_annotated_commits(&index, NULL, repo, one, two,
2257 0 0 GIT_ERROR_CHECK_ALLOC(result);
2285 6 0 if (given_opts)
2294 6 0 if ((error = insert_head_ids(&head_ids, two)) < 0 ||
6 0 if ((error = insert_head_ids(&head_ids, two)) < 0 ||
2295 6 0 (error = insert_head_ids(&head_ids, one)) < 0 ||
2300 6 0 base_count = (opts.flags & GIT_MERGE_NO_RECURSIVE) ? 0 : bases.count;
2302 6 0 if (base_count)
2305 0 6 if ((error = git_annotated_commit_lookup(&base, repo, &bases.ids[0])) < 0)
2308 0 6 for (i = 1; i < base_count; i++) {
2311 0 0 if (opts.recursion_limit && recursion_level > opts.recursion_limit)
0 0 if (opts.recursion_limit && recursion_level > opts.recursion_limit)
2314 0 0 if ((error = git_annotated_commit_lookup(&other, repo,
2315 0 0 &bases.ids[i])) < 0 ||
2329 6 0 if (error == 0)
2350 0 18 if (commit == NULL) {
2352 0 18 } else if (commit->type == GIT_ANNOTATED_COMMIT_VIRTUAL) {
2355 18 0 if (!commit->tree &&
0 18 if (!commit->tree &&
2379 0 6 if ((error = compute_base(&base, repo, ours, theirs, opts,
2382 0 0 if (error != GIT_ENOTFOUND)
2388 6 0 if ((error = iterator_for_annotated_commit(&base_iter, base)) < 0 ||
6 0 if ((error = iterator_for_annotated_commit(&base_iter, base)) < 0 ||
2389 6 0 (error = iterator_for_annotated_commit(&our_iter, ours)) < 0 ||
2390 6 0 (error = iterator_for_annotated_commit(&their_iter, theirs)) < 0 ||
2395 6 0 if (base_out) {
2419 1 0 if ((error = git_annotated_commit_from_commit(&ours, (git_commit *)our_commit)) < 0 ||
1 0 if ((error = git_annotated_commit_from_commit(&ours, (git_commit *)our_commit)) < 0 ||
2444 5 0 assert(repo && heads);
0 5 assert(repo && heads);
2446 5 0 if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_HEAD_FILE)) < 0 ||
5 0 if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_HEAD_FILE)) < 0 ||
2450 5 5 for (i = 0; i < heads_len; i++) {
2451 0 5 if ((error = git_filebuf_printf(&file, "%s\n", heads[i]->id_str)) < 0)
2458 0 5 if (error < 0)
2472 0 5 assert(repo);
2474 5 0 if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_MODE_FILE)) < 0 ||
5 0 if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_MODE_FILE)) < 0 ||
2478 0 5 if ((error = git_filebuf_write(&file, "no-ff", 5)) < 0)
2484 0 5 if (error < 0)
2503 5 0 return (entry->written == 0 &&
2504 5 0 entry->merge_head->remote_url == NULL &&
2505 5 0 entry->merge_head->ref_name != NULL &&
5 0 entry->merge_head->ref_name != NULL &&
2515 0 0 return (entry->written == 0 &&
2516 0 0 entry->merge_head->remote_url == NULL &&
2517 0 5 entry->merge_head->ref_name != NULL &&
0 0 entry->merge_head->ref_name != NULL &&
2527 0 0 return (entry->written == 0 &&
2528 0 0 entry->merge_head->remote_url == NULL &&
2529 0 5 entry->merge_head->ref_name != NULL &&
0 0 entry->merge_head->ref_name != NULL &&
2537 0 5 if (entry->written == 0 &&
0 0 if (entry->written == 0 &&
2538 0 0 entry->merge_head->remote_url != NULL &&
2539 0 0 entry->merge_head->ref_name != NULL &&
2545 0 0 if (entries->length == 0)
2560 0 5 return (merge_msg_entry->written == 0 &&
2561 5 0 merge_msg_entry->merge_head->ref_name == NULL &&
0 0 merge_msg_entry->merge_head->ref_name == NULL &&
2582 20 20 for (i = 0; i < len; i++) {
2583 0 20 if ((matches = match(&entries[i], v)) < 0)
2585 15 5 else if (!matches)
2608 10 5 if (entries->length == 0)
2611 0 5 if (sep && (error = git_filebuf_printf(file, "%c ", sep)) < 0)
0 0 if (sep && (error = git_filebuf_printf(file, "%c ", sep)) < 0)
2614 5 0 if ((error = git_filebuf_printf(file, "%s ",
0 5 if ((error = git_filebuf_printf(file, "%s ",
2618 5 5 git_vector_foreach(entries, i, entry) {
2619 0 5 if (i > 0 &&
0 0 if (i > 0 &&
2620 0 0 (error = git_filebuf_printf(file, "%s", (i == entries->length - 1) ? " and " : ", ")) < 0)
2623 0 5 if ((error = git_filebuf_printf(file, "'%s'", entry->merge_head->ref_name + ref_name_skip)) < 0)
2629 0 5 if (source)
2670 0 0 if (entries->length == 0)
2692 5 0 assert(repo && heads);
0 5 assert(repo && heads);
2695 0 5 GIT_ERROR_CHECK_ALLOC(entries);
2697 0 5 if (git_vector_init(&matching, heads_len, NULL) < 0) {
2702 5 5 for (i = 0; i < heads_len; i++)
2705 5 0 if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_MSG_FILE)) < 0 ||
5 0 if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_MSG_FILE)) < 0 ||
2706 5 0 (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_CREATE_LEADING_DIRS, GIT_MERGE_FILE_MODE)) < 0 ||
2721 5 0 for (i = 0; i < heads_len; i++) {
2722 5 0 if (!msg_entry_is_oid(&entries[i]))
2725 0 0 if ((error = git_filebuf_printf(&file,
0 0 if ((error = git_filebuf_printf(&file,
2733 0 5 if (i)
2736 5 0 if ((error = merge_msg_entries(&matching, entries, heads_len, msg_entry_is_branch)) < 0 ||
5 0 if ((error = merge_msg_entries(&matching, entries, heads_len, msg_entry_is_branch)) < 0 ||
2740 5 0 if (matching.length)
2743 5 0 if ((error = merge_msg_entries(&matching, entries, heads_len, msg_entry_is_tracking)) < 0 ||
5 0 if ((error = merge_msg_entries(&matching, entries, heads_len, msg_entry_is_tracking)) < 0 ||
2747 0 5 if (matching.length)
2750 5 0 if ((error = merge_msg_entries(&matching, entries, heads_len, msg_entry_is_tag)) < 0 ||
5 0 if ((error = merge_msg_entries(&matching, entries, heads_len, msg_entry_is_tag)) < 0 ||
2754 0 5 if (matching.length)
2759 0 5 while ((error = merge_msg_entries(&matching, entries, heads_len, msg_entry_is_remote)) > 0) {
2760 0 0 if ((error = merge_msg_write_remotes(&file, &matching, sep)) < 0)
2763 0 0 if (matching.length)
2767 0 5 if (error < 0)
2770 5 5 for (i = 0; i < heads_len; i++) {
2771 5 0 if (merge_msg_entry_written(&entries[i]))
2774 0 0 if ((error = git_filebuf_printf(&file, "; commit '%s'",
2779 5 0 if ((error = git_filebuf_printf(&file, "\n")) < 0 ||
2784 0 5 if (error < 0)
2803 5 0 assert (repo && our_head && heads);
5 0 assert (repo && our_head && heads);
0 5 assert (repo && our_head && heads);
2805 5 0 if ((error = git_repository__set_orig_head(repo, git_annotated_commit_id(our_head))) == 0 &&
5 0 if ((error = git_repository__set_orig_head(repo, git_annotated_commit_id(our_head))) == 0 &&
2806 5 0 (error = write_merge_head(repo, heads, heads_len)) == 0 &&
2827 5 0 assert(repo && our_head && their_heads);
5 0 assert(repo && our_head && their_heads);
0 5 assert(repo && our_head && their_heads);
2829 0 5 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, their_heads_len, 1);
0 5 GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, their_heads_len, 1);
2831 0 5 GIT_ERROR_CHECK_ALLOC(oids);
2835 5 5 for (i = 0; i < their_heads_len; i++)
2838 0 5 if ((error = git_merge_base_many(&ancestor_oid, repo, their_heads_len + 1, oids)) < 0)
2852 0 5 if ((slash = strrchr(branchname, '/')) == NULL)
2855 0 5 if (*(slash+1) == '\0')
2876 5 0 if (given_checkout_opts != NULL)
2883 5 0 if (!out->ancestor_label) {
2884 5 0 if (ancestor && ancestor->type == GIT_ANNOTATED_COMMIT_REAL)
5 0 if (ancestor && ancestor->type == GIT_ANNOTATED_COMMIT_REAL)
2886 0 0 else if (ancestor)
2892 5 0 if (!out->our_label) {
2893 5 0 if (our_head && our_head->ref_name)
5 0 if (our_head && our_head->ref_name)
2899 5 0 if (!out->their_label) {
2900 5 0 if (their_heads_len == 1 && their_heads[0]->ref_name)
5 0 if (their_heads_len == 1 && their_heads[0]->ref_name)
2902 0 0 else if (their_heads_len == 1)
2933 15 0 if ((error = git_repository_head_tree(&head_tree, repo)) < 0 ||
15 0 if ((error = git_repository_head_tree(&head_tree, repo)) < 0 ||
2934 15 0 (error = git_repository_index(&index_repo, repo)) < 0 ||
2938 12 3 if (staged_diff_list->deltas.length == 0)
2941 3 3 git_vector_foreach(&staged_diff_list->deltas, i, delta) {
2942 0 3 if ((error = git_vector_insert(&staged_paths, (char *)delta->new_file.path)) < 0)
2950 3 0 if ((error = git_iterator_for_index(&iter_repo, repo, index_repo, &iter_opts)) < 0 ||
3 0 if ((error = git_iterator_for_index(&iter_repo, repo, index_repo, &iter_opts)) < 0 ||
2951 3 0 (error = git_iterator_for_index(&iter_new, repo, index_new, &iter_opts)) < 0 ||
2986 2 13 if (merged_paths->length == 0)
3000 0 13 if ((error = git_diff_index_to_workdir(&wd_diff_list, repo, NULL, &opts)) < 0)
3026 15 0 if ((error = git_repository_head_tree(&head_tree, repo)) < 0 ||
15 0 if ((error = git_repository_head_tree(&head_tree, repo)) < 0 ||
3027 15 0 (error = git_iterator_for_tree(&iter_head, head_tree, &iter_opts)) < 0 ||
3028 15 0 (error = git_iterator_for_index(&iter_new, repo, index_new, &iter_opts)) < 0 ||
3032 12 15 git_vector_foreach(&merged_list->deltas, i, delta) {
3033 0 12 if ((error = git_vector_insert(&paths, (char *)delta->new_file.path)) < 0)
3037 39 15 for (i = 0; i < git_index_entrycount(index_new); i++) {
3041 0 10 (git_vector_last(&paths) == NULL ||
3044 0 1 if ((error = git_vector_insert(&paths, (char *)e->path)) < 0)
3050 15 0 if ((error = merge_check_index(&index_conflicts, repo, index_new, &paths)) < 0 ||
15 0 if ((error = merge_check_index(&index_conflicts, repo, index_new, &paths)) < 0 ||
3054 1 14 if ((conflicts = index_conflicts + wd_conflicts) > 0) {
3055 0 1 git_error_set(GIT_ERROR_MERGE, "%" PRIuZ " uncommitted change%s would be overwritten by merge",
3080 8 3 if (!git_index_has_conflicts(index))
3083 3 0 if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_MSG_FILE)) < 0 ||
3 0 if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_MSG_FILE)) < 0 ||
3089 11 3 for (i = 0; i < git_index_entrycount(index); i++) {
3092 2 9 if (!git_index_entry_is_conflict(e))
3095 6 3 if (last == NULL || strcmp(e->path, last) != 0)
0 6 if (last == NULL || strcmp(e->path, last) != 0)
3104 0 3 if (error < 0)
3137 0 5 if ((error = git_annotated_commit_from_ref(&our_head, repo, our_ref)) < 0)
3140 0 5 if ((error = merge_ancestor_head(&ancestor_head, repo, our_head, their_heads, their_heads_len)) < 0) {
3141 0 0 if (error != GIT_ENOTFOUND)
3152 0 5 if (error < 0) {
3168 0 5 if ((error = git_repository_config_snapshot(&config, repo)) < 0)
3171 5 0 if ((error = git_config_get_string(&value, config, "merge.ff")) < 0) {
3172 5 0 if (error == GIT_ENOTFOUND) {
3180 0 0 if (git_config_parse_bool(&bool_value, value) == 0) {
3181 0 0 if (!bool_value)
3184 0 0 if (strcasecmp(value, "only") == 0)
3205 5 0 assert(analysis_out && preference_out && repo && their_heads && their_heads_len > 0);
5 0 assert(analysis_out && preference_out && repo && their_heads && their_heads_len > 0);
5 0 assert(analysis_out && preference_out && repo && their_heads && their_heads_len > 0);
5 0 assert(analysis_out && preference_out && repo && their_heads && their_heads_len > 0);
0 5 assert(analysis_out && preference_out && repo && their_heads && their_heads_len > 0);
3207 0 5 if (their_heads_len != 1) {
3215 0 5 if ((error = merge_preference(preference_out, repo)) < 0)
3218 0 5 if ((error = git_reference__is_unborn_head(&unborn, our_ref, repo)) < 0)
3221 0 5 if (unborn) {
3227 0 5 if ((error = merge_heads(&ancestor_head, &our_head, repo, our_ref, their_heads, their_heads_len)) < 0)
3231 5 0 if (ancestor_head && git_oid_equal(
1 4 if (ancestor_head && git_oid_equal(
3236 4 0 else if (ancestor_head && git_oid_equal(
1 3 else if (ancestor_head && git_oid_equal(
3260 0 5 if ((error = git_reference_lookup(&head_ref, repo, GIT_HEAD_FILE)) < 0) {
3287 5 0 assert(repo && their_heads && their_heads_len > 0);
5 0 assert(repo && their_heads && their_heads_len > 0);
0 5 assert(repo && their_heads && their_heads_len > 0);
3289 0 5 if (their_heads_len != 1) {
3294 0 5 if ((error = git_repository__ensure_not_bare(repo, "merge")) < 0)
3298 5 0 given_checkout_opts->checkout_strategy :
3301 0 5 if ((error = git_indexwriter_init_for_operation(&indexwriter, repo,
3310 5 0 if ((error = git_annotated_commit_from_head(&our_head, repo)) < 0 ||
5 0 if ((error = git_annotated_commit_from_head(&our_head, repo)) < 0 ||
3317 5 0 if ((error = merge_annotated_commits(&index, &base, repo, our_head,
3318 5 0 (git_annotated_commit *)their_heads[0], 0, merge_opts)) < 0 ||
3319 5 0 (error = git_merge__check_result(repo, index)) < 0 ||
3325 5 0 if ((error = merge_normalize_checkout_opts(&checkout_opts, repo,
3327 5 0 base, our_head, their_heads, their_heads_len)) < 0 ||
3334 0 5 if (error < 0)
3349 0 0 GIT_INIT_STRUCTURE_FROM_TEMPLATE(
3363 0 0 GIT_INIT_STRUCTURE_FROM_TEMPLATE(
3378 0 0 GIT_INIT_STRUCTURE_FROM_TEMPLATE(