]> git.ipfire.org Git - thirdparty/git.git/blobdiff - pack-bitmap.c
Start the 2.46 cycle
[thirdparty/git.git] / pack-bitmap.c
index 2baeabacee13d4ec5311261499fe10d8f0a882e5..35c5ef9d3cd15ed34ecc3e77aee0d0f8eba766a5 100644 (file)
@@ -2049,7 +2049,10 @@ void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
 
        load_reverse_index(r, bitmap_git);
 
-       if (bitmap_is_midx(bitmap_git)) {
+       if (!bitmap_is_midx(bitmap_git) || !bitmap_git->midx->chunk_bitmapped_packs)
+               multi_pack_reuse = 0;
+
+       if (multi_pack_reuse) {
                for (i = 0; i < bitmap_git->midx->num_packs; i++) {
                        struct bitmapped_pack pack;
                        if (nth_bitmapped_pack(r, bitmap_git->midx, &pack, i) < 0) {
@@ -2062,34 +2065,32 @@ void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
                        if (!pack.bitmap_nr)
                                continue;
 
-                       if (!multi_pack_reuse && pack.bitmap_pos) {
-                               /*
-                                * If we're only reusing a single pack, skip
-                                * over any packs which are not positioned at
-                                * the beginning of the MIDX bitmap.
-                                *
-                                * This is consistent with the existing
-                                * single-pack reuse behavior, which only reuses
-                                * parts of the MIDX's preferred pack.
-                                */
-                               continue;
-                       }
-
                        ALLOC_GROW(packs, packs_nr + 1, packs_alloc);
                        memcpy(&packs[packs_nr++], &pack, sizeof(pack));
 
                        objects_nr += pack.p->num_objects;
-
-                       if (!multi_pack_reuse)
-                               break;
                }
 
                QSORT(packs, packs_nr, bitmapped_pack_cmp);
        } else {
-               ALLOC_GROW(packs, packs_nr + 1, packs_alloc);
+               struct packed_git *pack;
+
+               if (bitmap_is_midx(bitmap_git)) {
+                       uint32_t preferred_pack_pos;
+
+                       if (midx_preferred_pack(bitmap_git->midx, &preferred_pack_pos) < 0) {
+                               warning(_("unable to compute preferred pack, disabling pack-reuse"));
+                               return;
+                       }
 
-               packs[packs_nr].p = bitmap_git->pack;
-               packs[packs_nr].bitmap_nr = bitmap_git->pack->num_objects;
+                       pack = bitmap_git->midx->packs[preferred_pack_pos];
+               } else {
+                       pack = bitmap_git->pack;
+               }
+
+               ALLOC_GROW(packs, packs_nr + 1, packs_alloc);
+               packs[packs_nr].p = pack;
+               packs[packs_nr].bitmap_nr = pack->num_objects;
                packs[packs_nr].bitmap_pos = 0;
 
                objects_nr = packs[packs_nr++].bitmap_nr;