@@ -76,26 +76,29 @@ static void free_trees(void)
7676static void * run_index_diffs (void * arg )
7777{
7878 int thread = * (int * )arg ;
79+ git_repository * repo ;
7980 git_diff_options opts = GIT_DIFF_OPTIONS_INIT ;
8081 git_diff * diff = NULL ;
8182 size_t i ;
8283 int exp [4 ] = { 0 , 0 , 0 , 0 };
8384
85+ cl_git_pass (git_repository_open (& repo , git_repository_path (_repo )));
86+
8487 switch (thread & 0x03 ) {
8588 case 0 : /* diff index to workdir */ ;
86- cl_git_pass (git_diff_index_to_workdir (& diff , _repo , NULL , & opts ));
89+ cl_git_pass (git_diff_index_to_workdir (& diff , repo , NULL , & opts ));
8790 break ;
8891 case 1 : /* diff tree 'a' to index */ ;
89- cl_git_pass (git_diff_tree_to_index (& diff , _repo , _a , NULL , & opts ));
92+ cl_git_pass (git_diff_tree_to_index (& diff , repo , _a , NULL , & opts ));
9093 break ;
9194 case 2 : /* diff tree 'b' to index */ ;
92- cl_git_pass (git_diff_tree_to_index (& diff , _repo , _b , NULL , & opts ));
95+ cl_git_pass (git_diff_tree_to_index (& diff , repo , _b , NULL , & opts ));
9396 break ;
9497 case 3 : /* diff index to workdir (explicit index) */ ;
9598 {
9699 git_index * idx ;
97- cl_git_pass (git_repository_index (& idx , _repo ));
98- cl_git_pass (git_diff_index_to_workdir (& diff , _repo , idx , & opts ));
100+ cl_git_pass (git_repository_index (& idx , repo ));
101+ cl_git_pass (git_diff_index_to_workdir (& diff , repo , idx , & opts ));
99102 git_index_free (idx );
100103 break ;
101104 }
@@ -132,6 +135,7 @@ static void *run_index_diffs(void *arg)
132135 }
133136
134137 git_diff_free (diff );
138+ git_repository_free (repo );
135139 giterr_clear ();
136140
137141 return arg ;
@@ -152,8 +156,10 @@ static void *run_index_diffs_with_modifier(void *arg)
152156 git_diff_options opts = GIT_DIFF_OPTIONS_INIT ;
153157 git_diff * diff = NULL ;
154158 git_index * idx = NULL ;
159+ git_repository * repo ;
155160
156- cl_git_pass (git_repository_index (& idx , _repo ));
161+ cl_git_pass (git_repository_open (& repo , git_repository_path (_repo )));
162+ cl_git_pass (git_repository_index (& idx , repo ));
157163
158164 /* have first thread altering the index as we go */
159165 if (thread == 0 ) {
@@ -176,17 +182,17 @@ static void *run_index_diffs_with_modifier(void *arg)
176182
177183 switch (thread & 0x03 ) {
178184 case 0 : /* diff index to workdir */ ;
179- cl_git_pass (git_diff_index_to_workdir (& diff , _repo , idx , & opts ));
185+ cl_git_pass (git_diff_index_to_workdir (& diff , repo , idx , & opts ));
180186 break ;
181187 case 1 : /* diff tree 'a' to index */ ;
182- cl_git_pass (git_diff_tree_to_index (& diff , _repo , _a , idx , & opts ));
188+ cl_git_pass (git_diff_tree_to_index (& diff , repo , _a , idx , & opts ));
183189 break ;
184190 case 2 : /* diff tree 'b' to index */ ;
185- cl_git_pass (git_diff_tree_to_index (& diff , _repo , _b , idx , & opts ));
191+ cl_git_pass (git_diff_tree_to_index (& diff , repo , _b , idx , & opts ));
186192 break ;
187193 case 3 : /* diff index to workdir reversed */ ;
188194 opts .flags |= GIT_DIFF_REVERSE ;
189- cl_git_pass (git_diff_index_to_workdir (& diff , _repo , idx , & opts ));
195+ cl_git_pass (git_diff_index_to_workdir (& diff , repo , idx , & opts ));
190196 break ;
191197 }
192198
@@ -196,6 +202,7 @@ static void *run_index_diffs_with_modifier(void *arg)
196202
197203done :
198204 git_index_free (idx );
205+ git_repository_free (repo );
199206 giterr_clear ();
200207
201208 return arg ;
0 commit comments