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

Function unpack_delta_entry

builtin/unpack-objects.c:434–528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

432}
433
434static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
435 unsigned nr)
436{
437 void *delta_data, *base;
438 unsigned long base_size;
439 size_t base_size_st = 0;
440 struct object_id base_oid;
441
442 if (type == OBJ_REF_DELTA) {
443 oidread(&base_oid, fill(the_hash_algo->rawsz), the_repository->hash_algo);
444 use(the_hash_algo->rawsz);
445 delta_data = get_data(delta_size);
446 if (!delta_data)
447 return;
448 if (odb_has_object(the_repository->objects, &base_oid,
449 ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
450 ; /* Ok we have this one */
451 else if (resolve_against_held(nr, &base_oid,
452 delta_data, delta_size))
453 return; /* we are done */
454 else {
455 /* cannot resolve yet --- queue it */
456 oidclr(&obj_list[nr].oid, the_repository->hash_algo);
457 add_delta_to_list(nr, &base_oid, 0, delta_data, delta_size);
458 return;
459 }
460 } else {
461 unsigned base_found = 0;
462 unsigned char *pack, c;
463 off_t base_offset;
464 unsigned lo, mid, hi;
465
466 pack = fill(1);
467 c = *pack;
468 use(1);
469 base_offset = c & 127;
470 while (c & 128) {
471 base_offset += 1;
472 if (!base_offset || MSB(base_offset, 7))
473 die("offset value overflow for delta base object");
474 pack = fill(1);
475 c = *pack;
476 use(1);
477 base_offset = (base_offset << 7) + (c & 127);
478 }
479 base_offset = obj_list[nr].offset - base_offset;
480 if (base_offset <= 0 || base_offset >= obj_list[nr].offset)
481 die("offset value out of bound for delta base object");
482
483 delta_data = get_data(delta_size);
484 if (!delta_data)
485 return;
486 lo = 0;
487 hi = nr;
488 while (lo < hi) {
489 mid = lo + (hi - lo) / 2;
490 if (base_offset < obj_list[mid].offset) {
491 hi = mid;

Callers 1

unpack_oneFunction · 0.85

Calls 15

oidreadFunction · 0.85
get_dataFunction · 0.85
odb_has_objectFunction · 0.85
resolve_against_heldFunction · 0.85
oidclrFunction · 0.85
add_delta_to_listFunction · 0.85
oidcpyFunction · 0.85
is_null_oidFunction · 0.85
null_oidFunction · 0.85
odb_read_objectFunction · 0.85
cast_size_t_to_ulongFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected