@@ -146,35 +146,31 @@ struct expand_id_test_data expand_id_test_data[] = {
146146};
147147
148148static void setup_prefix_query (
149- git_oid * * out_ids ,
150- size_t * * out_lengths ,
151- git_otype * * out_types ,
149+ git_odb_expand_id * * out_ids ,
152150 size_t * out_num )
153151{
154- git_oid * ids ;
155- git_otype * types ;
156- size_t num , * lengths , i ;
152+ git_odb_expand_id * ids ;
153+ size_t num , i ;
157154
158155 num = ARRAY_SIZE (expand_id_test_data );
159156
160- cl_assert ((ids = git__calloc (num , sizeof (git_oid ))));
161- cl_assert ((lengths = git__calloc (num , sizeof (size_t ))));
162- cl_assert ((types = git__calloc (num , sizeof (git_otype ))));
157+ cl_assert ((ids = git__calloc (num , sizeof (git_odb_expand_id ))));
163158
164159 for (i = 0 ; i < num ; i ++ ) {
165- lengths [i ] = strlen (expand_id_test_data [i ].lookup_id );
166- git_oid_fromstrn (& ids [i ], expand_id_test_data [i ].lookup_id , lengths [i ]);
167- types [i ] = expand_id_test_data [i ].expected_type ;
160+ git_odb_expand_id * id = & ids [i ];
161+
162+ size_t len = strlen (expand_id_test_data [i ].lookup_id );
163+
164+ git_oid_fromstrn (& id -> id , expand_id_test_data [i ].lookup_id , len );
165+ id -> length = (unsigned short )len ;
166+ id -> type = expand_id_test_data [i ].expected_type ;
168167 }
169168
170169 * out_ids = ids ;
171- * out_lengths = lengths ;
172- * out_types = types ;
173170 * out_num = num ;
174171}
175172
176- static void assert_found_objects (
177- git_oid * ids , size_t * lengths , git_otype * types )
173+ static void assert_found_objects (git_odb_expand_id * ids )
178174{
179175 size_t num , i ;
180176
@@ -191,71 +187,70 @@ static void assert_found_objects(
191187 expected_type = expand_id_test_data [i ].expected_type ;
192188 }
193189
194- cl_assert_equal_i (expected_len , lengths [i ]);
195- cl_assert_equal_oid (& expected_id , & ids [i ]);
196-
197- if (types )
198- cl_assert_equal_i (expected_type , types [i ]);
190+ cl_assert_equal_oid (& expected_id , & ids [i ].id );
191+ cl_assert_equal_i (expected_len , ids [i ].length );
192+ cl_assert_equal_i (expected_type , ids [i ].type );
199193 }
200194}
201195
202- static void assert_notfound_objects (
203- git_oid * ids , size_t * lengths , git_otype * types )
196+ static void assert_notfound_objects (git_odb_expand_id * ids )
204197{
205198 git_oid expected_id = {{0 }};
206199 size_t num , i ;
207200
208201 num = ARRAY_SIZE (expand_id_test_data );
209202
210203 for (i = 0 ; i < num ; i ++ ) {
211- cl_assert_equal_i (0 , lengths [i ]);
212- cl_assert_equal_oid (& expected_id , & ids [i ]);
213-
214- if (types )
215- cl_assert_equal_i (0 , types [i ]);
204+ cl_assert_equal_oid (& expected_id , & ids [i ].id );
205+ cl_assert_equal_i (0 , ids [i ].length );
206+ cl_assert_equal_i (0 , ids [i ].type );
216207 }
217208}
218209
219210void test_odb_mixed__expand_ids (void )
220211{
221- git_oid * ids ;
222- size_t i , num , * lengths ;
223- git_otype * types ;
212+ git_odb_expand_id * ids ;
213+ size_t i , num ;
224214
225215 /* test looking for the actual (correct) types */
226216
227- setup_prefix_query (& ids , & lengths , & types , & num );
228- cl_git_pass (git_odb_expand_ids (_odb , ids , lengths , types , num ));
229- assert_found_objects (ids , lengths , types );
230- git__free (ids ); git__free (lengths ); git__free (types );
217+ setup_prefix_query (& ids , & num );
218+ cl_git_pass (git_odb_expand_ids (_odb , ids , num ));
219+ assert_found_objects (ids );
220+ git__free (ids );
221+
222+ /* test looking for an explicit `type == 0` */
231223
232- /* test looking for no specified types (types array == NULL) */
224+ setup_prefix_query (& ids , & num );
225+
226+ for (i = 0 ; i < num ; i ++ )
227+ ids [i ].type = 0 ;
233228
234- setup_prefix_query (& ids , & lengths , & types , & num );
235- cl_git_pass (git_odb_expand_ids (_odb , ids , lengths , NULL , num ));
236- assert_found_objects (ids , lengths , NULL );
237- git__free (ids ); git__free (lengths ); git__free (types );
229+ cl_git_pass (git_odb_expand_ids (_odb , ids , num ));
230+ assert_found_objects (ids );
231+ git__free (ids );
238232
239233 /* test looking for an explicit GIT_OBJ_ANY */
240234
241- setup_prefix_query (& ids , & lengths , & types , & num );
235+ setup_prefix_query (& ids , & num );
242236
243237 for (i = 0 ; i < num ; i ++ )
244- types [i ] = GIT_OBJ_ANY ;
238+ ids [i ]. type = GIT_OBJ_ANY ;
245239
246- cl_git_pass (git_odb_expand_ids (_odb , ids , lengths , types , num ));
247- assert_found_objects (ids , lengths , types );
248- git__free (ids ); git__free ( lengths ); git__free ( types );
240+ cl_git_pass (git_odb_expand_ids (_odb , ids , num ));
241+ assert_found_objects (ids );
242+ git__free (ids );
249243
250244 /* test looking for the completely wrong type */
251245
252- setup_prefix_query (& ids , & lengths , & types , & num );
246+ setup_prefix_query (& ids , & num );
253247
254248 for (i = 0 ; i < num ; i ++ )
255- types [i ] = (types [i ] == GIT_OBJ_BLOB ) ? GIT_OBJ_TREE : GIT_OBJ_BLOB ;
249+ ids [i ].type = (ids [i ].type == GIT_OBJ_BLOB ) ?
250+ GIT_OBJ_TREE : GIT_OBJ_BLOB ;
256251
257- cl_git_pass (git_odb_expand_ids (_odb , ids , lengths , types , num ));
258- assert_notfound_objects (ids , lengths , types );
259- git__free (ids ); git__free ( lengths ); git__free ( types );
252+ cl_git_pass (git_odb_expand_ids (_odb , ids , num ));
253+ assert_notfound_objects (ids );
254+ git__free (ids );
260255}
261256
0 commit comments