@@ -543,6 +543,7 @@ void assert_conflict(
543543 */
544544 cl_git_pass (git_object_peel (& hack_tree , g_object , GIT_OBJ_TREE ));
545545 cl_git_pass (git_index_read_tree (index , (git_tree * )hack_tree ));
546+ cl_git_pass (git_index_write (index ));
546547 git_object_free (hack_tree );
547548 git_object_free (g_object );
548549 g_object = NULL ;
@@ -671,9 +672,12 @@ void test_checkout_tree__can_cancel_checkout_from_notify(void)
671672 git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT ;
672673 git_oid oid ;
673674 git_object * obj = NULL ;
675+ git_index * index = NULL ;
674676
675677 assert_on_branch (g_repo , "master" );
676678
679+ cl_git_pass (git_repository_index (& index , g_repo ));
680+
677681 cl_git_pass (git_reference_name_to_id (& oid , g_repo , "refs/heads/dir" ));
678682 cl_git_pass (git_object_lookup (& obj , g_repo , & oid , GIT_OBJ_ANY ));
679683
@@ -700,6 +704,8 @@ void test_checkout_tree__can_cancel_checkout_from_notify(void)
700704 else
701705 cl_assert_equal_i (4 , ca .count );
702706
707+ cl_git_pass (git_index_read (index , 1 ));
708+
703709 /* and again with a different stopping point and return code */
704710 ca .filename = "README" ;
705711 ca .error = 123 ;
@@ -715,6 +721,7 @@ void test_checkout_tree__can_cancel_checkout_from_notify(void)
715721 cl_assert_equal_i (1 , ca .count );
716722
717723 git_object_free (obj );
724+ git_index_free (index );
718725}
719726
720727void test_checkout_tree__can_checkout_with_last_workdir_item_missing (void )
@@ -739,7 +746,9 @@ void test_checkout_tree__can_checkout_with_last_workdir_item_missing(void)
739746 cl_git_mkfile ("./testrepo/this-is-dir/contained_file" , "content\n" );
740747
741748 cl_git_pass (git_index_add_bypath (index , "this-is-dir/contained_file" ));
742- git_index_write_tree (& tree_id , index );
749+ cl_git_pass (git_index_write (index ));
750+
751+ cl_git_pass (git_index_write_tree (& tree_id , index ));
743752 cl_git_pass (git_tree_lookup (& tree , g_repo , & tree_id ));
744753
745754 cl_git_pass (p_unlink ("./testrepo/this-is-dir/contained_file" ));
@@ -1107,7 +1116,7 @@ void test_checkout_tree__removes_conflicts(void)
11071116 git_commit * commit ;
11081117 git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT ;
11091118 git_index * index ;
1110-
1119+
11111120 cl_git_pass (git_oid_fromstr (& commit_id , "afe4393b2b2a965f06acf2ca9658eaa01e0cd6b6" ));
11121121 cl_git_pass (git_commit_lookup (& commit , g_repo , & commit_id ));
11131122
@@ -1150,7 +1159,7 @@ void test_checkout_tree__removes_conflicts_only_by_pathscope(void)
11501159 git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT ;
11511160 git_index * index ;
11521161 const char * path = "executable.txt" ;
1153-
1162+
11541163 cl_git_pass (git_oid_fromstr (& commit_id , "afe4393b2b2a965f06acf2ca9658eaa01e0cd6b6" ));
11551164 cl_git_pass (git_commit_lookup (& commit , g_repo , & commit_id ));
11561165
@@ -1248,7 +1257,7 @@ void test_checkout_tree__case_changing_rename(void)
12481257
12491258 cl_git_pass (git_checkout_tree (g_repo , (git_object * )master_commit , & opts ));
12501259 cl_git_pass (git_repository_set_head (g_repo , "refs/heads/master" ));
1251-
1260+
12521261 assert_on_branch (g_repo , "master" );
12531262
12541263 cl_assert (git_path_isfile ("testrepo/README" ));
@@ -1493,8 +1502,11 @@ void test_checkout_tree__baseline_is_empty_when_no_index(void)
14931502 git_reference * head ;
14941503 git_object * obj ;
14951504 size_t conflicts = 0 ;
1505+ git_index * index ;
14961506
14971507 assert_on_branch (g_repo , "master" );
1508+
1509+ cl_git_pass (git_repository_index (& index , g_repo ));
14981510 cl_git_pass (git_repository_head (& head , g_repo ));
14991511 cl_git_pass (git_reference_peel (& obj , head , GIT_OBJ_COMMIT ));
15001512
@@ -1513,6 +1525,8 @@ void test_checkout_tree__baseline_is_empty_when_no_index(void)
15131525 cl_git_fail_with (GIT_ECONFLICT , git_checkout_tree (g_repo , obj , & opts ));
15141526 cl_assert_equal_i (4 , conflicts );
15151527
1528+ cl_git_pass (git_index_read (index , 1 ));
1529+
15161530 /* but force should succeed and update the index */
15171531 opts .checkout_strategy |= GIT_CHECKOUT_FORCE ;
15181532 cl_git_pass (git_checkout_tree (g_repo , obj , & opts ));
@@ -1521,6 +1535,7 @@ void test_checkout_tree__baseline_is_empty_when_no_index(void)
15211535
15221536 git_object_free (obj );
15231537 git_reference_free (head );
1538+ git_index_free (index );
15241539}
15251540
15261541void test_checkout_tree__mode_change_is_force_updated (void )
@@ -1551,8 +1566,12 @@ void test_checkout_tree__mode_change_is_force_updated(void)
15511566 cl_must_pass (p_chmod ("testrepo/README" , 0755 ));
15521567 cl_must_pass (git_index_add_bypath (index , "README" ));
15531568
1569+ cl_git_pass (git_index_write (index ));
15541570 assert_status_entrycount (g_repo , 1 );
1571+
15551572 cl_git_pass (git_checkout_tree (g_repo , obj , & g_opts ));
1573+ cl_git_pass (git_index_write (index ));
1574+
15561575 assert_status_entrycount (g_repo , 0 );
15571576
15581577 git_object_free (obj );
0 commit comments