2267
uint32_t pack_pos,
2268
off_t offset,
2269
struct bitmap *reuse,
2270
- struct pack_window **w_curs)
2270
+ struct pack_window **w_curs,
2271
+ int allow_ref_delta)
2272
{
2273
off_t delta_obj_offset;
2274
enum object_type type;
2287
uint32_t base_pos;
2288
uint32_t base_bitmap_pos;
2289
2290
+ if (type == OBJ_REF_DELTA && !allow_ref_delta)
2291
+ return 0;
2292
+
2293
/*
2294
* Find the position of the base object so we can look it up
2295
* in our bitmaps. If we can't come up with an offset, or if
2362
2363
static void reuse_partial_packfile_from_bitmap_1(struct bitmap_index *bitmap_git,
2364
struct bitmapped_pack *pack,
2361
- struct bitmap *reuse)
2365
+ struct bitmap *reuse,
2366
+ int allow_ref_delta)
2367
{
2368
struct bitmap *result = bitmap_git->result;
2369
struct pack_window *w_curs = NULL;
2370
size_t pos = pack->bitmap_pos / BITS_IN_EWORD;
2371
2367
- if (!pack->bitmap_pos) {
2372
+ if (allow_ref_delta && !pack->bitmap_pos) {
2373
/*
2374
* If we're processing the first (in the case of a MIDX, the
2375
* preferred pack) or the only (in the case of single-pack
2371
- * bitmaps) pack, then we can reuse whole words at a time.
2372
- *
2373
- * This is because we know that any deltas in this range *must*
2374
- * have their bases chosen from the same pack, since:
2376
+ * bitmaps) pack, then any delta in this range must have its
2377
+ * base chosen from the same pack:
2378
*
2379
* - In the single pack case, there is no other pack to choose
2380
* them from.
2383
* all ties are broken in favor of that pack (i.e. the one
2384
* we're currently processing). So any duplicate bases will be
2385
* resolved in favor of the pack we're processing.
2386
+ *
2387
+ * When REF_DELTAs are allowed, we can therefore reuse whole
2388
+ * words at a time without inspecting object headers. Otherwise,
2389
+ * inspect each object below to avoid reusing a REF_DELTA entry.
2390
*/
2391
while (pos < result->word_alloc &&
2392
pos < pack->bitmap_nr / BITS_IN_EWORD &&
2436
}
2437
2438
if (try_partial_reuse(bitmap_git, pack, bit_pos,
2432
- pack_pos, ofs, reuse, &w_curs) < 0) {
2439
+ pack_pos, ofs, reuse, &w_curs,
2440
+ allow_ref_delta) < 0) {
2441
/*
2442
* try_partial_reuse indicated we couldn't reuse
2443
* any bits, so there is no point in trying more
2472
struct bitmapped_pack **packs_out,
2473
size_t *packs_nr_out,
2474
struct bitmap **reuse_out,
2467
- int multi_pack_reuse)
2475
+ int multi_pack_reuse,
2476
+ int allow_ref_delta)
2477
{
2478
struct repository *r = bitmap_repo(bitmap_git);
2479
struct bitmapped_pack *packs = NULL;
2568
reuse = bitmap_word_alloc(word_alloc);
2569
2570
for (i = 0; i < packs_nr; i++)
2562
- reuse_partial_packfile_from_bitmap_1(bitmap_git, &packs[i], reuse);
2571
+ reuse_partial_packfile_from_bitmap_1(bitmap_git, &packs[i], reuse,
2572
+ allow_ref_delta);
2573
2574
if (bitmap_is_empty(reuse)) {
2575
free(packs);