@@ -723,7 +723,7 @@ void test_status_renames__rename_threshold(void)
723723 git_index * index ;
724724 git_status_list * statuslist ;
725725 git_status_options opts = GIT_STATUS_OPTIONS_INIT ;
726-
726+
727727 _rename_helper (g_repo , "ikeepsix.txt" , "newname.txt" ,
728728 "Line 1\n" \
729729 "Line 2\n" \
@@ -735,49 +735,110 @@ void test_status_renames__rename_threshold(void)
735735 "Line 8\n" \
736736 "Line 9\n"
737737 );
738-
738+
739739 opts .flags |= GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR ;
740740 opts .flags |= GIT_STATUS_OPT_INCLUDE_UNTRACKED ;
741-
741+
742742 cl_git_pass (git_repository_index (& index , g_repo ));
743-
744- // Default threshold
743+
744+ /* Default threshold */
745745 {
746746 struct status_entry expected [] = {
747747 { GIT_STATUS_WT_RENAMED | GIT_STATUS_WT_MODIFIED , "ikeepsix.txt" , "newname.txt" },
748748 };
749-
749+
750750 cl_git_pass (git_status_list_new (& statuslist , g_repo , & opts ));
751751 check_status (statuslist , expected , 1 );
752752 git_status_list_free (statuslist );
753753 }
754-
755- // Threshold set to 90
754+
755+ /* Threshold set to 90 */
756756 {
757757 struct status_entry expected [] = {
758758 { GIT_STATUS_WT_DELETED , "ikeepsix.txt" , NULL },
759759 { GIT_STATUS_WT_NEW , "newname.txt" , NULL }
760760 };
761-
761+
762762 opts .rename_threshold = 90 ;
763-
763+
764764 cl_git_pass (git_status_list_new (& statuslist , g_repo , & opts ));
765765 check_status (statuslist , expected , 2 );
766766 git_status_list_free (statuslist );
767767 }
768-
769- // Threshold set to 25
768+
769+ /* Threshold set to 25 */
770770 {
771771 struct status_entry expected [] = {
772772 { GIT_STATUS_WT_RENAMED | GIT_STATUS_WT_MODIFIED , "ikeepsix.txt" , "newname.txt" },
773773 };
774-
774+
775775 opts .rename_threshold = 25 ;
776-
776+
777777 cl_git_pass (git_status_list_new (& statuslist , g_repo , & opts ));
778778 check_status (statuslist , expected , 1 );
779779 git_status_list_free (statuslist );
780780 }
781-
781+
782782 git_index_free (index );
783783}
784+
785+ void test_status_renames__case_insensitive_h2i_and_i2wc (void )
786+ {
787+ git_status_list * statuslist ;
788+ git_status_options opts = GIT_STATUS_OPTIONS_INIT ;
789+ git_reference * head , * test_branch ;
790+ git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT ;
791+ git_str path_to_delete = GIT_STR_INIT ;
792+ git_str path_to_edit = GIT_STR_INIT ;
793+ git_index * index ;
794+ git_strarray paths = { NULL , 0 };
795+
796+ struct status_entry expected [] = {
797+ { GIT_STATUS_INDEX_RENAMED | GIT_STATUS_WT_MODIFIED , "sixserving.txt" , "sixserving-renamed.txt" },
798+ { GIT_STATUS_INDEX_DELETED , "Wow.txt" , "Wow.txt" }
799+ };
800+
801+
802+ /* Checkout the correct branch */
803+ checkout_opts .checkout_strategy = GIT_CHECKOUT_FORCE ;
804+ cl_git_pass (git_reference_lookup (& head , g_repo , "HEAD" ));
805+ cl_git_pass (git_reference_symbolic_set_target (
806+ & test_branch , head , "refs/heads/case-insensitive-status" , NULL ));
807+ cl_git_pass (git_checkout_head (g_repo , & checkout_opts ));
808+
809+ cl_git_pass (git_repository_index (& index , g_repo ));
810+
811+
812+ /* Rename sixserving.txt, delete Wow.txt, and stage those changes */
813+ rename_file (g_repo , "sixserving.txt" , "sixserving-renamed.txt" );
814+ cl_git_pass (git_str_joinpath (
815+ & path_to_delete , git_repository_workdir (g_repo ), "Wow.txt" ));
816+ cl_git_rmfile (path_to_delete .ptr );
817+
818+ cl_git_pass (git_index_add_all (index , & paths , GIT_INDEX_ADD_FORCE , NULL , NULL ));
819+ cl_git_pass (git_index_write (index ));
820+
821+
822+ /* Change content of sixserving-renamed.txt */
823+ cl_git_pass (git_str_joinpath (
824+ & path_to_edit , git_repository_workdir (g_repo ), "sixserving-renamed.txt" ));
825+ cl_git_append2file (path_to_edit .ptr , "New content\n" );
826+
827+ /* Run status */
828+ opts .flags |= GIT_STATUS_OPT_INCLUDE_UNTRACKED ;
829+ opts .flags |= GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR ;
830+ opts .flags |= GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX ;
831+ opts .flags |= GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY ;
832+
833+ cl_git_pass (git_status_list_new (& statuslist , g_repo , & opts ));
834+ check_status (statuslist , expected , 2 );
835+ git_status_list_free (statuslist );
836+
837+ git_index_free (index );
838+
839+ git_str_dispose (& path_to_delete );
840+ git_str_dispose (& path_to_edit );
841+
842+ git_reference_free (head );
843+ git_reference_free (test_branch );
844+ }
0 commit comments