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

Function fill_midx_entry

midx.c:592–628  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

590}
591
592int fill_midx_entry(struct multi_pack_index *m,
593 const struct object_id *oid,
594 struct pack_entry *e)
595{
596 uint32_t pos;
597 uint32_t pack_int_id;
598 struct packed_git *p;
599
600 if (!bsearch_midx(oid, m, &pos))
601 return 0;
602
603 midx_for_object(&m, pos);
604 pack_int_id = nth_midxed_pack_int_id(m, pos);
605
606 if (prepare_midx_pack(m, pack_int_id))
607 return 0;
608 p = m->packs[pack_int_id - m->num_packs_in_base];
609
610 /*
611 * We are about to tell the caller where they can locate the
612 * requested object. We better make sure the packfile is
613 * still here and can be accessed before supplying that
614 * answer, as it may have been deleted since the MIDX was
615 * loaded!
616 */
617 if (!is_pack_valid(p))
618 return 0;
619
620 if (oidset_size(&p->bad_objects) &&
621 oidset_contains(&p->bad_objects, oid))
622 return 0;
623
624 e->offset = nth_midxed_offset(m, pos);
625 e->p = p;
626
627 return 1;
628}
629
630/* Match "foo.idx" against either "foo.pack" _or_ "foo.idx". */
631int cmp_idx_or_pack_name(const char *idx_or_pack_name,

Callers 4

find_pack_entryFunction · 0.85
verify_midx_fileFunction · 0.85
read_midx_fileFunction · 0.85

Calls 8

bsearch_midxFunction · 0.85
midx_for_objectFunction · 0.85
nth_midxed_pack_int_idFunction · 0.85
prepare_midx_packFunction · 0.85
is_pack_validFunction · 0.85
oidset_sizeFunction · 0.85
oidset_containsFunction · 0.85
nth_midxed_offsetFunction · 0.85

Tested by 1

read_midx_fileFunction · 0.68