@@ -183,7 +183,7 @@ static void do_conflicted_diff(diff_expects *exp, unsigned long flags)
183
183
cl_git_pass (git_repository_index (& index , g_repo ));
184
184
185
185
ancestor .path = ours .path = theirs .path = "staged_changes" ;
186
- ancestor .mode = ours .mode = theirs .mode = 0100644 ;
186
+ ancestor .mode = ours .mode = theirs .mode = GIT_FILEMODE_BLOB ;
187
187
188
188
git_oid_fromstr (& ancestor .id , "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" );
189
189
git_oid_fromstr (& ours .id , "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" );
@@ -239,3 +239,32 @@ void test_diff_index__reports_conflicts_when_reversed(void)
239
239
cl_assert_equal_i (2 , exp .line_adds );
240
240
cl_assert_equal_i (5 , exp .line_dels );
241
241
}
242
+
243
+ void test_diff_index__not_in_head_conflicted (void )
244
+ {
245
+ const char * a_commit = "26a125ee1bf" ; /* the current HEAD */
246
+ git_index_entry theirs = {{0 }};
247
+ git_index * index ;
248
+ git_diff * diff ;
249
+ const git_diff_delta * delta ;
250
+
251
+ git_tree * a = resolve_commit_oid_to_tree (g_repo , a_commit );
252
+
253
+ cl_git_pass (git_repository_index (& index , g_repo ));
254
+ cl_git_pass (git_index_read_tree (index , a ));
255
+
256
+ theirs .path = "file_not_in_head" ;
257
+ theirs .mode = GIT_FILEMODE_BLOB ;
258
+ git_oid_fromstr (& theirs .id , "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef" );
259
+ cl_git_pass (git_index_conflict_add (index , NULL , NULL , & theirs ));
260
+
261
+ cl_git_pass (git_diff_tree_to_index (& diff , g_repo , a , index , NULL ));
262
+
263
+ cl_assert_equal_i (git_diff_num_deltas (diff ), 1 );
264
+ delta = git_diff_get_delta (diff , 0 );
265
+ cl_assert_equal_i (delta -> status , GIT_DELTA_CONFLICTED );
266
+
267
+ git_diff_free (diff );
268
+ git_index_free (index );
269
+ git_tree_free (a );
270
+ }
0 commit comments