@@ -342,3 +342,94 @@ void test_index_conflicts__partial(void)
342
342
cl_assert (conflict_entry [1 ] == NULL );
343
343
cl_assert (conflict_entry [2 ] == NULL );
344
344
}
345
+
346
+ void test_index_conflicts__case_matters (void )
347
+ {
348
+ const git_index_entry * conflict_entry [3 ];
349
+ git_oid oid ;
350
+ const char * upper_case = "DIFFERS-IN-CASE.TXT" ;
351
+ const char * mixed_case = "Differs-In-Case.txt" ;
352
+ const char * correct_case ;
353
+ bool ignorecase = cl_repo_get_bool (repo , "core.ignorecase" );
354
+
355
+ git_index_entry ancestor_entry , our_entry , their_entry ;
356
+
357
+ memset (& ancestor_entry , 0x0 , sizeof (git_index_entry ));
358
+ memset (& our_entry , 0x0 , sizeof (git_index_entry ));
359
+ memset (& their_entry , 0x0 , sizeof (git_index_entry ));
360
+
361
+ ancestor_entry .path = upper_case ;
362
+ GIT_IDXENTRY_STAGE_SET (& ancestor_entry , GIT_INDEX_STAGE_ANCESTOR );
363
+ git_oid_fromstr (& ancestor_entry .id , CONFLICTS_ONE_ANCESTOR_OID );
364
+ ancestor_entry .mode = GIT_FILEMODE_BLOB ;
365
+
366
+ our_entry .path = upper_case ;
367
+ GIT_IDXENTRY_STAGE_SET (& our_entry , GIT_INDEX_STAGE_OURS );
368
+ git_oid_fromstr (& our_entry .id , CONFLICTS_ONE_OUR_OID );
369
+ our_entry .mode = GIT_FILEMODE_BLOB ;
370
+
371
+ their_entry .path = upper_case ;
372
+ GIT_IDXENTRY_STAGE_SET (& their_entry , GIT_INDEX_STAGE_THEIRS );
373
+ git_oid_fromstr (& their_entry .id , CONFLICTS_ONE_THEIR_OID );
374
+ their_entry .mode = GIT_FILEMODE_BLOB ;
375
+
376
+ cl_git_pass (git_index_conflict_add (repo_index ,
377
+ & ancestor_entry , & our_entry , & their_entry ));
378
+
379
+ ancestor_entry .path = mixed_case ;
380
+ GIT_IDXENTRY_STAGE_SET (& ancestor_entry , GIT_INDEX_STAGE_ANCESTOR );
381
+ git_oid_fromstr (& ancestor_entry .id , CONFLICTS_TWO_ANCESTOR_OID );
382
+ ancestor_entry .mode = GIT_FILEMODE_BLOB ;
383
+
384
+ our_entry .path = mixed_case ;
385
+ GIT_IDXENTRY_STAGE_SET (& ancestor_entry , GIT_INDEX_STAGE_ANCESTOR );
386
+ git_oid_fromstr (& our_entry .id , CONFLICTS_TWO_OUR_OID );
387
+ ancestor_entry .mode = GIT_FILEMODE_BLOB ;
388
+
389
+ their_entry .path = mixed_case ;
390
+ GIT_IDXENTRY_STAGE_SET (& their_entry , GIT_INDEX_STAGE_THEIRS );
391
+ git_oid_fromstr (& their_entry .id , CONFLICTS_TWO_THEIR_OID );
392
+ their_entry .mode = GIT_FILEMODE_BLOB ;
393
+
394
+ cl_git_pass (git_index_conflict_add (repo_index ,
395
+ & ancestor_entry , & our_entry , & their_entry ));
396
+
397
+ cl_git_pass (git_index_conflict_get (& conflict_entry [0 ], & conflict_entry [1 ],
398
+ & conflict_entry [2 ], repo_index , upper_case ));
399
+
400
+ /*
401
+ * We inserted with mixed case last, so on a case-insensitive
402
+ * fs we should get the mixed case.
403
+ */
404
+ if (ignorecase )
405
+ correct_case = mixed_case ;
406
+ else
407
+ correct_case = upper_case ;
408
+
409
+ cl_assert_equal_s (correct_case , conflict_entry [0 ]-> path );
410
+ git_oid_fromstr (& oid , ignorecase ? CONFLICTS_TWO_ANCESTOR_OID : CONFLICTS_ONE_ANCESTOR_OID );
411
+ cl_assert_equal_oid (& oid , & conflict_entry [0 ]-> id );
412
+
413
+ cl_assert_equal_s (correct_case , conflict_entry [1 ]-> path );
414
+ git_oid_fromstr (& oid , ignorecase ? CONFLICTS_TWO_OUR_OID : CONFLICTS_ONE_OUR_OID );
415
+ cl_assert_equal_oid (& oid , & conflict_entry [1 ]-> id );
416
+
417
+ cl_assert_equal_s (correct_case , conflict_entry [2 ]-> path );
418
+ git_oid_fromstr (& oid , ignorecase ? CONFLICTS_TWO_THEIR_OID : CONFLICTS_ONE_THEIR_OID );
419
+ cl_assert_equal_oid (& oid , & conflict_entry [2 ]-> id );
420
+
421
+ cl_git_pass (git_index_conflict_get (& conflict_entry [0 ], & conflict_entry [1 ],
422
+ & conflict_entry [2 ], repo_index , mixed_case ));
423
+
424
+ cl_assert_equal_s (mixed_case , conflict_entry [0 ]-> path );
425
+ git_oid_fromstr (& oid , CONFLICTS_TWO_ANCESTOR_OID );
426
+ cl_assert_equal_oid (& oid , & conflict_entry [0 ]-> id );
427
+
428
+ cl_assert_equal_s (mixed_case , conflict_entry [1 ]-> path );
429
+ git_oid_fromstr (& oid , CONFLICTS_TWO_OUR_OID );
430
+ cl_assert_equal_oid (& oid , & conflict_entry [1 ]-> id );
431
+
432
+ cl_assert_equal_s (mixed_case , conflict_entry [2 ]-> path );
433
+ git_oid_fromstr (& oid , CONFLICTS_TWO_THEIR_OID );
434
+ cl_assert_equal_oid (& oid , & conflict_entry [2 ]-> id );
435
+ }
0 commit comments