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

Function unpack_one

builtin/unpack-objects.c:530–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

528}
529
530static void unpack_one(unsigned nr)
531{
532 unsigned shift;
533 unsigned char *pack;
534 size_t size, c;
535 enum object_type type;
536
537 obj_list[nr].offset = consumed_bytes;
538
539 pack = fill(1);
540 c = *pack;
541 use(1);
542 type = (c >> 4) & 7;
543 size = (c & 15);
544 shift = 4;
545 while (c & 0x80) {
546 if ((bitsizeof(size_t) - 7) < shift)
547 die(_("object size too large for this platform"));
548 pack = fill(1);
549 c = *pack;
550 use(1);
551 size += (c & 0x7f) << shift;
552 shift += 7;
553 }
554
555 switch (type) {
556 case OBJ_BLOB:
557 if (!dry_run &&
558 size > repo_settings_get_big_file_threshold(the_repository)) {
559 stream_blob(size, nr);
560 return;
561 }
562 /* fallthrough */
563 case OBJ_COMMIT:
564 case OBJ_TREE:
565 case OBJ_TAG:
566 unpack_non_delta_entry(type, size, nr);
567 return;
568 case OBJ_REF_DELTA:
569 case OBJ_OFS_DELTA:
570 unpack_delta_entry(type, size, nr);
571 return;
572 default:
573 error("bad object type %d", type);
574 has_errors = 1;
575 if (recover)
576 return;
577 exit(1);
578 }
579}
580
581static void unpack_all(void)
582{

Callers 1

unpack_allFunction · 0.85

Calls 8

unpack_non_delta_entryFunction · 0.85
unpack_delta_entryFunction · 0.85
errorFunction · 0.85
fillFunction · 0.70
useFunction · 0.70
stream_blobFunction · 0.70
dieFunction · 0.50

Tested by

no test coverage detected