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

Function reuse_partial_packfile_from_bitmap

pack-bitmap.c:2462–2577  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2460}
2461
2462void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
2463 struct bitmapped_pack **packs_out,
2464 size_t *packs_nr_out,
2465 struct bitmap **reuse_out,
2466 int multi_pack_reuse)
2467{
2468 struct repository *r = bitmap_repo(bitmap_git);
2469 struct bitmapped_pack *packs = NULL;
2470 struct bitmap *result = bitmap_git->result;
2471 struct bitmap *reuse;
2472 size_t i;
2473 size_t packs_nr = 0, packs_alloc = 0;
2474 size_t word_alloc;
2475 uint32_t objects_nr = 0;
2476
2477 assert(result);
2478
2479 load_reverse_index(r, bitmap_git);
2480
2481 if (!bitmap_is_midx(bitmap_git) || !bitmap_git->midx->chunk_bitmapped_packs)
2482 multi_pack_reuse = 0;
2483
2484 if (multi_pack_reuse) {
2485 struct multi_pack_index *m = bitmap_git->midx;
2486 for (i = 0; i < m->num_packs + m->num_packs_in_base; i++) {
2487 struct bitmapped_pack pack;
2488 if (nth_bitmapped_pack(bitmap_git->midx, &pack, i) < 0) {
2489 warning(_("unable to load pack: '%s', disabling pack-reuse"),
2490 bitmap_git->midx->pack_names[i]);
2491 free(packs);
2492 return;
2493 }
2494
2495 if (!pack.bitmap_nr)
2496 continue;
2497
2498 if (is_pack_valid(pack.p)) {
2499 ALLOC_GROW(packs, packs_nr + 1, packs_alloc);
2500 memcpy(&packs[packs_nr++], &pack, sizeof(pack));
2501 }
2502
2503 objects_nr += pack.p->num_objects;
2504 }
2505
2506 QSORT(packs, packs_nr, bitmapped_pack_cmp);
2507 } else {
2508 struct packed_git *pack;
2509 uint32_t pack_int_id;
2510
2511 if (bitmap_is_midx(bitmap_git)) {
2512 struct multi_pack_index *m = bitmap_git->midx;
2513 uint32_t preferred_pack_pos;
2514
2515 while (m->base_midx)
2516 m = m->base_midx;
2517
2518 if (midx_preferred_pack(m, &preferred_pack_pos) < 0) {
2519 warning(_("unable to compute preferred pack, disabling pack-reuse"));

Callers 1

Calls 13

bitmap_repoFunction · 0.85
load_reverse_indexFunction · 0.85
bitmap_is_midxFunction · 0.85
nth_bitmapped_packFunction · 0.85
warningFunction · 0.85
is_pack_validFunction · 0.85
midx_preferred_packFunction · 0.85
nth_midxed_packFunction · 0.85
bitmap_word_allocFunction · 0.85
bitmap_is_emptyFunction · 0.85
bitmap_freeFunction · 0.85

Tested by

no test coverage detected