@@ -10,6 +10,16 @@ static git_repository *g_repo;
1010static git_checkout_options g_opts ;
1111static git_object * g_object ;
1212
13+ static void assert_status_entrycount (git_repository * repo , size_t count )
14+ {
15+ git_status_list * status ;
16+
17+ cl_git_pass (git_status_list_new (& status , repo , NULL ));
18+ cl_assert_equal_i (count , git_status_list_entrycount (status ));
19+
20+ git_status_list_free (status );
21+ }
22+
1323void test_checkout_tree__initialize (void )
1424{
1525 g_repo = cl_git_sandbox_init ("testrepo" );
@@ -1480,7 +1490,6 @@ void test_checkout_tree__baseline_is_empty_when_no_index(void)
14801490 git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT ;
14811491 git_reference * head ;
14821492 git_object * obj ;
1483- git_status_list * status ;
14841493 size_t conflicts = 0 ;
14851494
14861495 assert_on_branch (g_repo , "master" );
@@ -1506,9 +1515,7 @@ void test_checkout_tree__baseline_is_empty_when_no_index(void)
15061515 opts .checkout_strategy |= GIT_CHECKOUT_FORCE ;
15071516 cl_git_pass (git_checkout_tree (g_repo , obj , & opts ));
15081517
1509- cl_git_pass (git_status_list_new (& status , g_repo , NULL ));
1510- cl_assert_equal_i (0 , git_status_list_entrycount (status ));
1511- git_status_list_free (status );
1518+ assert_status_entrycount (g_repo , 0 );
15121519
15131520 git_object_free (obj );
15141521 git_reference_free (head );
@@ -1519,7 +1526,6 @@ void test_checkout_tree__mode_change_is_force_updated(void)
15191526 git_index * index ;
15201527 git_reference * head ;
15211528 git_object * obj ;
1522- git_status_list * status ;
15231529
15241530 if (!cl_is_chmod_supported ())
15251531 clar__skip ();
@@ -1530,29 +1536,22 @@ void test_checkout_tree__mode_change_is_force_updated(void)
15301536 cl_git_pass (git_reference_peel (& obj , head , GIT_OBJ_COMMIT ));
15311537
15321538 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 );
1539+ assert_status_entrycount (g_repo , 0 );
15371540
15381541 /* update the mode on-disk */
15391542 cl_must_pass (p_chmod ("testrepo/README" , 0755 ));
15401543
1544+ assert_status_entrycount (g_repo , 1 );
15411545 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+ assert_status_entrycount (g_repo , 0 );
15461547
15471548 /* update the mode on-disk and in the index */
15481549 cl_must_pass (p_chmod ("testrepo/README" , 0755 ));
15491550 cl_must_pass (git_index_add_bypath (index , "README" ));
15501551
1552+ assert_status_entrycount (g_repo , 1 );
15511553 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 );
1554+ assert_status_entrycount (g_repo , 0 );
15561555
15571556 git_object_free (obj );
15581557 git_reference_free (head );
0 commit comments