@@ -718,3 +718,66 @@ void test_status_renames__precomposed_unicode_toggle_is_rename(void)
718718#endif
719719}
720720
721+ void test_status_renames__rename_threshold (void )
722+ {
723+ git_index * index ;
724+ git_status_list * statuslist ;
725+ git_status_options opts = GIT_STATUS_OPTIONS_INIT ;
726+
727+ _rename_helper (g_repo , "ikeepsix.txt" , "newname.txt" ,
728+ "Line 1\n" \
729+ "Line 2\n" \
730+ "Line 3\n" \
731+ "Line 4\n" \
732+ "Line 5\n" \
733+ "Line 6\n" \
734+ "Line 7\n" \
735+ "Line 8\n" \
736+ "Line 9\n"
737+ );
738+
739+ opts .flags |= GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR ;
740+ opts .flags |= GIT_STATUS_OPT_INCLUDE_UNTRACKED ;
741+
742+ cl_git_pass (git_repository_index (& index , g_repo ));
743+
744+ // Default threshold
745+ {
746+ struct status_entry expected [] = {
747+ { GIT_STATUS_WT_RENAMED | GIT_STATUS_WT_MODIFIED , "ikeepsix.txt" , "newname.txt" },
748+ };
749+
750+ cl_git_pass (git_status_list_new (& statuslist , g_repo , & opts ));
751+ check_status (statuslist , expected , 1 );
752+ git_status_list_free (statuslist );
753+ }
754+
755+ // Threshold set to 90
756+ {
757+ struct status_entry expected [] = {
758+ { GIT_STATUS_WT_DELETED , "ikeepsix.txt" , NULL },
759+ { GIT_STATUS_WT_NEW , "newname.txt" , NULL }
760+ };
761+
762+ opts .rename_threshold = 90 ;
763+
764+ cl_git_pass (git_status_list_new (& statuslist , g_repo , & opts ));
765+ check_status (statuslist , expected , 2 );
766+ git_status_list_free (statuslist );
767+ }
768+
769+ // Threshold set to 25
770+ {
771+ struct status_entry expected [] = {
772+ { GIT_STATUS_WT_RENAMED | GIT_STATUS_WT_MODIFIED , "ikeepsix.txt" , "newname.txt" },
773+ };
774+
775+ opts .rename_threshold = 25 ;
776+
777+ cl_git_pass (git_status_list_new (& statuslist , g_repo , & opts ));
778+ check_status (statuslist , expected , 1 );
779+ git_status_list_free (statuslist );
780+ }
781+
782+ git_index_free (index );
783+ }
0 commit comments