@@ -1514,6 +1514,51 @@ void test_checkout_tree__baseline_is_empty_when_no_index(void)
15141514 git_reference_free (head );
15151515}
15161516
1517+ void test_checkout_tree__mode_change_is_force_updated (void )
1518+ {
1519+ git_index * index ;
1520+ git_reference * head ;
1521+ git_object * obj ;
1522+ git_status_list * status ;
1523+
1524+ if (!cl_is_chmod_supported ())
1525+ clar__skip ();
1526+
1527+ assert_on_branch (g_repo , "master" );
1528+ cl_git_pass (git_repository_index (& index , g_repo ));
1529+ cl_git_pass (git_repository_head (& head , g_repo ));
1530+ cl_git_pass (git_reference_peel (& obj , head , GIT_OBJ_COMMIT ));
1531+
1532+ cl_git_pass (git_reset (g_repo , obj , GIT_RESET_HARD , NULL ));
1533+
1534+ cl_git_pass (git_status_list_new (& status , g_repo , NULL ));
1535+ cl_assert_equal_i (0 , git_status_list_entrycount (status ));
1536+ git_status_list_free (status );
1537+
1538+ /* update the mode on-disk */
1539+ cl_must_pass (p_chmod ("testrepo/README" , 0755 ));
1540+
1541+ cl_git_pass (git_checkout_tree (g_repo , obj , & g_opts ));
1542+
1543+ cl_git_pass (git_status_list_new (& status , g_repo , NULL ));
1544+ cl_assert_equal_i (0 , git_status_list_entrycount (status ));
1545+ git_status_list_free (status );
1546+
1547+ /* update the mode on-disk and in the index */
1548+ cl_must_pass (p_chmod ("testrepo/README" , 0755 ));
1549+ cl_must_pass (git_index_add_bypath (index , "README" ));
1550+
1551+ cl_git_pass (git_checkout_tree (g_repo , obj , & g_opts ));
1552+
1553+ cl_git_pass (git_status_list_new (& status , g_repo , NULL ));
1554+ cl_assert_equal_i (0 , git_status_list_entrycount (status ));
1555+ git_status_list_free (status );
1556+
1557+ git_object_free (obj );
1558+ git_reference_free (head );
1559+ git_index_free (index );
1560+ }
1561+
15171562void test_checkout_tree__nullopts (void )
15181563{
15191564 cl_git_pass (git_checkout_tree (g_repo , NULL , NULL ));
0 commit comments