| 2397 | } |
| 2398 | |
| 2399 | static int for_each_prefixed_object_in_midx( |
| 2400 | struct packfile_store *store, |
| 2401 | struct multi_pack_index *m, |
| 2402 | const struct odb_for_each_object_options *opts, |
| 2403 | struct packfile_store_for_each_object_wrapper_data *data) |
| 2404 | { |
| 2405 | int ret; |
| 2406 | |
| 2407 | for (; m; m = m->base_midx) { |
| 2408 | uint32_t num, i, first = 0; |
| 2409 | int len = opts->prefix_hex_len > m->source->odb->repo->hash_algo->hexsz ? |
| 2410 | m->source->odb->repo->hash_algo->hexsz : opts->prefix_hex_len; |
| 2411 | |
| 2412 | if (!m->num_objects) |
| 2413 | continue; |
| 2414 | |
| 2415 | num = m->num_objects + m->num_objects_in_base; |
| 2416 | |
| 2417 | bsearch_one_midx(opts->prefix, m, &first); |
| 2418 | |
| 2419 | /* |
| 2420 | * At this point, "first" is the location of the lowest |
| 2421 | * object with an object name that could match "opts->prefix". |
| 2422 | * See if we have 0, 1 or more objects that actually match(es). |
| 2423 | */ |
| 2424 | for (i = first; i < num; i++) { |
| 2425 | const struct object_id *current = NULL; |
| 2426 | struct object_id oid; |
| 2427 | |
| 2428 | current = nth_midxed_object_oid(&oid, m, i); |
| 2429 | |
| 2430 | if (!match_hash(len, opts->prefix->hash, current->hash)) |
| 2431 | break; |
| 2432 | |
| 2433 | if (data->request) { |
| 2434 | struct object_info oi = *data->request; |
| 2435 | |
| 2436 | ret = packfile_store_read_object_info(store, current, |
| 2437 | &oi, 0); |
| 2438 | if (ret) |
| 2439 | goto out; |
| 2440 | |
| 2441 | ret = data->cb(&oid, &oi, data->cb_data); |
| 2442 | if (ret) |
| 2443 | goto out; |
| 2444 | } else { |
| 2445 | ret = data->cb(&oid, NULL, data->cb_data); |
| 2446 | if (ret) |
| 2447 | goto out; |
| 2448 | } |
| 2449 | } |
| 2450 | } |
| 2451 | |
| 2452 | ret = 0; |
| 2453 | |
| 2454 | out: |
| 2455 | return ret; |
| 2456 | } |
no test coverage detected