MCPcopy Create free account
hub / github.com/git/git / for_each_prefixed_object_in_pack

Function for_each_prefixed_object_in_pack

packfile.c:2458–2505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2456}
2457
2458static int for_each_prefixed_object_in_pack(
2459 struct packfile_store *store,
2460 struct packed_git *p,
2461 const struct odb_for_each_object_options *opts,
2462 struct packfile_store_for_each_object_wrapper_data *data)
2463{
2464 uint32_t num, i, first = 0;
2465 int len = opts->prefix_hex_len > p->repo->hash_algo->hexsz ?
2466 p->repo->hash_algo->hexsz : opts->prefix_hex_len;
2467 int ret;
2468
2469 num = p->num_objects;
2470 bsearch_pack(opts->prefix, p, &first);
2471
2472 /*
2473 * At this point, "first" is the location of the lowest object
2474 * with an object name that could match "bin_pfx". See if we have
2475 * 0, 1 or more objects that actually match(es).
2476 */
2477 for (i = first; i < num; i++) {
2478 struct object_id oid;
2479
2480 nth_packed_object_id(&oid, p, i);
2481 if (!match_hash(len, opts->prefix->hash, oid.hash))
2482 break;
2483
2484 if (data->request) {
2485 struct object_info oi = *data->request;
2486
2487 ret = packfile_store_read_object_info(store, &oid, &oi, 0);
2488 if (ret)
2489 goto out;
2490
2491 ret = data->cb(&oid, &oi, data->cb_data);
2492 if (ret)
2493 goto out;
2494 } else {
2495 ret = data->cb(&oid, NULL, data->cb_data);
2496 if (ret)
2497 goto out;
2498 }
2499 }
2500
2501 ret = 0;
2502
2503out:
2504 return ret;
2505}
2506
2507static int packfile_store_for_each_prefixed_object(
2508 struct packfile_store *store,

Calls 4

bsearch_packFunction · 0.85
nth_packed_object_idFunction · 0.85
match_hashFunction · 0.85

Tested by

no test coverage detected