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

Function unpack_raw_entry

builtin/index-pack.c:520–588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

518}
519
520static void *unpack_raw_entry(struct object_entry *obj,
521 off_t *ofs_offset,
522 struct object_id *ref_oid,
523 struct object_id *oid)
524{
525 unsigned char *p;
526 size_t size, c;
527 off_t base_offset;
528 unsigned shift;
529 void *data;
530
531 obj->idx.offset = consumed_bytes;
532 input_crc32 = crc32(0, NULL, 0);
533
534 p = fill(1);
535 c = *p;
536 use(1);
537 obj->type = (c >> 4) & 7;
538 size = (c & 15);
539 shift = 4;
540 while (c & 0x80) {
541 if ((bitsizeof(size_t) - 7) < shift)
542 die(_("object size too large for this platform"));
543 p = fill(1);
544 c = *p;
545 use(1);
546 size += (c & 0x7f) << shift;
547 shift += 7;
548 }
549 obj->size = size;
550
551 switch (obj->type) {
552 case OBJ_REF_DELTA:
553 oidread(ref_oid, fill(the_hash_algo->rawsz),
554 the_repository->hash_algo);
555 use(the_hash_algo->rawsz);
556 break;
557 case OBJ_OFS_DELTA:
558 p = fill(1);
559 c = *p;
560 use(1);
561 base_offset = c & 127;
562 while (c & 128) {
563 base_offset += 1;
564 if (!base_offset || MSB(base_offset, 7))
565 bad_object(obj->idx.offset, _("offset value overflow for delta base object"));
566 p = fill(1);
567 c = *p;
568 use(1);
569 base_offset = (base_offset << 7) + (c & 127);
570 }
571 *ofs_offset = obj->idx.offset - base_offset;
572 if (*ofs_offset <= 0 || *ofs_offset >= obj->idx.offset)
573 bad_object(obj->idx.offset, _("delta base offset is out of bound"));
574 break;
575 case OBJ_COMMIT:
576 case OBJ_TREE:
577 case OBJ_BLOB:

Callers 1

parse_pack_objectsFunction · 0.85

Calls 6

oidreadFunction · 0.85
bad_objectFunction · 0.85
unpack_entry_dataFunction · 0.85
fillFunction · 0.70
useFunction · 0.70
dieFunction · 0.50

Tested by

no test coverage detected