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

Function midx_layer_contains_pack

midx.c:670–707  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

668}
669
670int midx_layer_contains_pack(struct multi_pack_index *m,
671 const char *idx_or_pack_name)
672{
673 uint32_t first = 0, last = m->num_packs;
674
675 if (m->version == MIDX_VERSION_V2 && !m->pack_names_sorted) {
676 uint32_t i;
677
678 ALLOC_ARRAY(m->pack_names_sorted, m->num_packs);
679
680 for (i = 0; i < m->num_packs; i++)
681 m->pack_names_sorted[i] = i;
682
683 QSORT_S(m->pack_names_sorted, m->num_packs, midx_pack_names_cmp,
684 m);
685 }
686
687 while (first < last) {
688 uint32_t mid = first + (last - first) / 2;
689 const char *current;
690 int cmp;
691
692 if (m->pack_names_sorted)
693 current = m->pack_names[m->pack_names_sorted[mid]];
694 else
695 current = m->pack_names[mid];
696 cmp = cmp_idx_or_pack_name(idx_or_pack_name, current);
697 if (!cmp)
698 return 1;
699 if (cmp > 0) {
700 first = mid + 1;
701 continue;
702 }
703 last = mid;
704 }
705
706 return 0;
707}
708
709int midx_contains_pack(struct multi_pack_index *m, const char *idx_or_pack_name)
710{

Callers 2

pack_geometry_initFunction · 0.85
midx_contains_packFunction · 0.85

Calls 1

cmp_idx_or_pack_nameFunction · 0.85

Tested by

no test coverage detected