@@ -1745,3 +1745,39 @@ void test_diff_workdir__binary_detection(void)
1745
1745
git_index_free (idx );
1746
1746
git_buf_free (& b );
1747
1747
}
1748
+
1749
+ void test_diff_workdir__to_index_conflicted (void ) {
1750
+ const char * a_commit = "26a125ee1bf" ; /* the current HEAD */
1751
+ git_index_entry ancestor = {{0 }}, ours = {{0 }}, theirs = {{0 }};
1752
+ git_tree * a ;
1753
+ git_index * index ;
1754
+ git_diff * diff1 , * diff2 ;
1755
+ const git_diff_delta * delta ;
1756
+
1757
+ g_repo = cl_git_sandbox_init ("status" );
1758
+ a = resolve_commit_oid_to_tree (g_repo , a_commit );
1759
+
1760
+ cl_git_pass (git_repository_index (& index , g_repo ));
1761
+
1762
+ ancestor .path = ours .path = theirs .path = "_file" ;
1763
+ ancestor .mode = ours .mode = theirs .mode = 0100644 ;
1764
+ git_oid_fromstr (& ancestor .id , "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" );
1765
+ git_oid_fromstr (& ours .id , "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" );
1766
+ git_oid_fromstr (& theirs .id , "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" );
1767
+ cl_git_pass (git_index_conflict_add (index , & ancestor , & ours , & theirs ));
1768
+
1769
+ cl_git_pass (git_diff_tree_to_index (& diff1 , g_repo , a , index , NULL ));
1770
+ cl_git_pass (git_diff_index_to_workdir (& diff2 , g_repo , index , NULL ));
1771
+ cl_git_pass (git_diff_merge (diff1 , diff2 ));
1772
+
1773
+ cl_assert_equal_i (git_diff_num_deltas (diff1 ), 12 );
1774
+ delta = git_diff_get_delta (diff1 , 0 );
1775
+ cl_assert_equal_s (delta -> old_file .path , "_file" );
1776
+ cl_assert_equal_i (delta -> nfiles , 1 );
1777
+ cl_assert_equal_i (delta -> status , GIT_DELTA_CONFLICTED );
1778
+
1779
+ git_diff_free (diff2 );
1780
+ git_diff_free (diff1 );
1781
+ git_index_free (index );
1782
+ git_tree_free (a );
1783
+ }
0 commit comments